aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels van Dijke <perlboy@cpan.org>2022-12-05 14:49:55 +0000
committerNiels van Dijke <perlboy@cpan.org>2022-12-05 14:49:55 +0000
commit4824fac55259f93f017fbe28fced25070cf8c71b (patch)
treebf7e958e4b07bdc99c33ee17c814e7c742091c82
parente322903f5ac8dd899a5b157369ed79ff970e6784 (diff)
downloadperlweeklychallenge-club-4824fac55259f93f017fbe28fced25070cf8c71b.tar.gz
perlweeklychallenge-club-4824fac55259f93f017fbe28fced25070cf8c71b.tar.bz2
perlweeklychallenge-club-4824fac55259f93f017fbe28fced25070cf8c71b.zip
Task 1 - Trap invalid format
-rwxr-xr-xchallenge-194/perlboy1967/perl/ch-1.pl4
1 files changed, 2 insertions, 2 deletions
diff --git a/challenge-194/perlboy1967/perl/ch-1.pl b/challenge-194/perlboy1967/perl/ch-1.pl
index 4b4638403d..8826c9ba6b 100755
--- a/challenge-194/perlboy1967/perl/ch-1.pl
+++ b/challenge-194/perlboy1967/perl/ch-1.pl
@@ -25,11 +25,11 @@ use Test::More;
sub highestDigit ($) {
state $c = { -1=>-1, 0=>2, 1=>9, 2=>-1, 3=>5, 4=>9 };
- $c->{index($_[0],'?')}
+ ($_[0] =~ y/?/?/) != 1 ? -1 : $c->{index($_[0],'?')}
}
-my %t = qw(?0:00 2 1?:00 9 10:?2 5 12:1? 9);
+my %t = qw(?0:00 2 1?:00 9 10:?2 5 12:1? 9 ??:00 -1 00?00 -1);
for (sort keys %t) {
is(highestDigit($_),$t{$_},"highestDigit('$_')");