diff options
| author | Luca Ferrari <fluca1978@gmail.com> | 2023-03-06 14:27:32 +0100 |
|---|---|---|
| committer | Luca Ferrari <fluca1978@gmail.com> | 2023-03-06 14:27:32 +0100 |
| commit | c9b06033cc830ad98c41f599d770c4707ec51b39 (patch) | |
| tree | 21b7d8b77562e69503bda94a767fd4ffe4f52b50 | |
| parent | 0f5dafd2a98bacb9993430b3d128800623a3b1fd (diff) | |
| download | perlweeklychallenge-club-c9b06033cc830ad98c41f599d770c4707ec51b39.tar.gz perlweeklychallenge-club-c9b06033cc830ad98c41f599d770c4707ec51b39.tar.bz2 perlweeklychallenge-club-c9b06033cc830ad98c41f599d770c4707ec51b39.zip | |
Task 1 plperl done
| -rw-r--r-- | challenge-207/luca-ferrari/postgresql/ch-1.plperl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-207/luca-ferrari/postgresql/ch-1.plperl b/challenge-207/luca-ferrari/postgresql/ch-1.plperl new file mode 100644 index 0000000000..f40c97ae1e --- /dev/null +++ b/challenge-207/luca-ferrari/postgresql/ch-1.plperl @@ -0,0 +1,34 @@ +-- +-- Perl Weekly Challenge 207 +-- Task 1 +-- See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-207/> +-- + +CREATE SCHEMA IF NOT EXISTS pwc207; + +CREATE OR REPLACE FUNCTION +pwc207.task1_plperl( text[] ) +RETURNS SETOF text +AS $CODE$ + + my ( $words ) = @_; + my ( @keyboard ) = qw/ qwertyuiop asdfghjkl zxcvbnm /; + + for my $current_word ( $words->@* ) { + for my $current_row ( @keyboard ) { + my $found = 0; + for my $current_letter ( split( '', lc( $current_word ) ) ) { + $found++ if ( $current_row =~ /$current_letter/ ); + } + + if ( scalar( split( '', $current_word ) ) == $found ) { + return_next( $current_word ); + last; + } + } + } + + return undef; + +$CODE$ +LANGUAGE plperl; |
