aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2022-10-03 10:59:37 +0200
committerLuca Ferrari <fluca1978@gmail.com>2022-10-03 10:59:37 +0200
commitdd79f10dfd7f9915b173787349fcb22b3639f81a (patch)
treefbb7a4c0223cad626867fc60996c22ba86cb5975
parent9e9bb92d4b8dca13c73b28ea23d861e32d975839 (diff)
downloadperlweeklychallenge-club-dd79f10dfd7f9915b173787349fcb22b3639f81a.tar.gz
perlweeklychallenge-club-dd79f10dfd7f9915b173787349fcb22b3639f81a.tar.bz2
perlweeklychallenge-club-dd79f10dfd7f9915b173787349fcb22b3639f81a.zip
Task 2 plperl done
-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;