aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-185/luca-ferrari/postgresql/ch-2.plperl21
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-185/luca-ferrari/postgresql/ch-2.plperl b/challenge-185/luca-ferrari/postgresql/ch-2.plperl
new file mode 100644
index 0000000000..162a7c9762
--- /dev/null
+++ b/challenge-185/luca-ferrari/postgresql/ch-2.plperl
@@ -0,0 +1,21 @@
+-- Perl Weekly Challenge 185
+-- Task 2
+
+CREATE SCHEMA IF NOT EXISTS pwc185;
+
+CREATE OR REPLACE FUNCTION
+pwc185.task2_plperl( text )
+RETURNS text
+AS $CODE$
+my ( $input ) = @_;
+my @output;
+my $counter = 4;
+
+for ( split( //, $input ) ) {
+ push @output, 'x' and $counter-- and next if ( /[a-z0-9]/i ) and $counter > 0;
+ push @output, $_;
+}
+
+return join( '', @output );
+$CODE$
+LANGUAGE plperl;