diff options
| -rw-r--r-- | challenge-184/luca-ferrari/postgresql/ch-1.plperl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-184/luca-ferrari/postgresql/ch-1.plperl b/challenge-184/luca-ferrari/postgresql/ch-1.plperl new file mode 100644 index 0000000000..a47a35e5b9 --- /dev/null +++ b/challenge-184/luca-ferrari/postgresql/ch-1.plperl @@ -0,0 +1,22 @@ +-- Perl Weekly Challenge 184 +-- Task 1 + +CREATE SCHEMA IF NOT EXISTS pwc184; + +CREATE OR REPLACE FUNCTION +pwc184.task1_plperl( text[] ) +RETURNS SETOF text +AS $CODE$ + +my $counter = 0; +for my $current_string ( @{$_[0]} ) { + next if $current_string !~ / ^ [a-z]{2} \d{4} $ /ix; + $counter = sprintf "%02d", $counter; + $current_string =~ s/ ^ [a-z]{2} /$counter/xi; + $counter++; + return_next( $current_string ); +} + +return undef(); +$CODE$ +LANGUAGE plperl; |
