aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2022-12-06 08:05:11 +0100
committerLuca Ferrari <fluca1978@gmail.com>2022-12-06 08:05:11 +0100
commit345f4b5979521b5905cf91c460a1e6217e9f4b2f (patch)
tree835cbc63c47661139770b2156c8693c5eb012314
parent8e8f3299d4447ec1f8cc0e52522ae2543535439c (diff)
downloadperlweeklychallenge-club-345f4b5979521b5905cf91c460a1e6217e9f4b2f.tar.gz
perlweeklychallenge-club-345f4b5979521b5905cf91c460a1e6217e9f4b2f.tar.bz2
perlweeklychallenge-club-345f4b5979521b5905cf91c460a1e6217e9f4b2f.zip
Task 1 plperl done
-rw-r--r--challenge-194/luca-ferrari/postgresql/ch-1.plperl31
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-194/luca-ferrari/postgresql/ch-1.plperl b/challenge-194/luca-ferrari/postgresql/ch-1.plperl
new file mode 100644
index 0000000000..62445dd0df
--- /dev/null
+++ b/challenge-194/luca-ferrari/postgresql/ch-1.plperl
@@ -0,0 +1,31 @@
+-- Perl Weekly Challenge 194
+-- Task 1
+
+CREATE SCHEMA IF NOT EXISTS pwc194;
+
+CREATE OR REPLACE FUNCTION
+pwc194.task1_plperl( text )
+RETURNS int
+AS $CODE$
+ my ($what) = @_;
+
+ if ( $what =~ / ^ ([\d?]) ([\d?]) : ([\d?]) ([\d?]) $ /x ) {
+ if ( $1 eq '?' ) {
+ return 9;
+ }
+ elsif ( $2 eq '?' ) {
+ return 3 if $1 == 2;
+ return 9;
+ }
+ elsif ( $3 eq '?' ) {
+ return 5;
+ }
+ else {
+ return 9;
+ }
+ }
+
+return undef;
+
+$CODE$
+LANGUAGE plperl;