aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-207/james-smith/perl/ch-1.pl22
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 <>;