diff options
| author | James Smith <js5@sanger.ac.uk> | 2023-03-12 08:42:08 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-12 08:42:08 +0000 |
| commit | aa6b154a8f7b5f643b566f3ee8913026998ce4b4 (patch) | |
| tree | 61a9ecd0e3f69ea1023e137cd4322a2b9cfe97ec /challenge-207 | |
| parent | 33c228c577d6ca63cba6571081a8a43dec55471a (diff) | |
| download | perlweeklychallenge-club-aa6b154a8f7b5f643b566f3ee8913026998ce4b4.tar.gz perlweeklychallenge-club-aa6b154a8f7b5f643b566f3ee8913026998ce4b4.tar.bz2 perlweeklychallenge-club-aa6b154a8f7b5f643b566f3ee8913026998ce4b4.zip | |
Create ch-1.pl
Diffstat (limited to 'challenge-207')
| -rw-r--r-- | challenge-207/james-smith/perl/ch-1.pl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-207/james-smith/perl/ch-1.pl b/challenge-207/james-smith/perl/ch-1.pl new file mode 100644 index 0000000000..d0e5cecd65 --- /dev/null +++ b/challenge-207/james-smith/perl/ch-1.pl @@ -0,0 +1,22 @@ +#!/usr/local/bin/perl + +use strict; +use warnings; +use feature qw(say); +use Test::More; + +my @TESTS = ( + [ [qw(Hello Alaska Dad Peace)], 'Alaska Dad' ], + [ [qw(OMG Bye) ], '' ], +); + +sub keyboard_words { grep { m{^([qwertyuiop]+|[asdfghjkl]+|[zxcvbnm]+)$}i } @_ } +sub keyboard_word { $_[0] =~ m{^([qwertyuiop]+|[asdfghjkl]+|[zxcvbnm]+)$}i } + +done_testing(); + +is( "@{[ keyboard_words( @{$_->[0]} ) ]}", $_->[1] ) for @TESTS; + +## This one looks for all keyboard words in a file... + +m{^([qwertyuiop]+|[asdfghjkl]+|[zxcvbnm]+)$}i && print while <>; |
