diff options
| author | Abigail <abigail@abigail.be> | 2021-04-26 17:24:16 +0200 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-04-26 17:24:16 +0200 |
| commit | fade7f9cc20b4a6bd64313aa3f07ac2e40c10a5e (patch) | |
| tree | af48c5635f7acea976e7425ba9099e8edd12f494 | |
| parent | 2afd5f937984d0e308df4c65e04ebaed3cff00fa (diff) | |
| download | perlweeklychallenge-club-fade7f9cc20b4a6bd64313aa3f07ac2e40c10a5e.tar.gz perlweeklychallenge-club-fade7f9cc20b4a6bd64313aa3f07ac2e40c10a5e.tar.bz2 perlweeklychallenge-club-fade7f9cc20b4a6bd64313aa3f07ac2e40c10a5e.zip | |
Perl solution for week 110, part 1
| -rw-r--r-- | challenge-110/abigail/README.md | 1 | ||||
| -rw-r--r-- | challenge-110/abigail/perl/ch-1.pl | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-110/abigail/README.md b/challenge-110/abigail/README.md index 0de651abe6..789f3d845f 100644 --- a/challenge-110/abigail/README.md +++ b/challenge-110/abigail/README.md @@ -41,6 +41,7 @@ We therefore conclude the examples just contain random spaces, and we can completly ignore any white space in the input. ### Solutions +[Perl](perl/ch-1.pl) ### Blog diff --git a/challenge-110/abigail/perl/ch-1.pl b/challenge-110/abigail/perl/ch-1.pl new file mode 100644 index 0000000000..4ddafea3f1 --- /dev/null +++ b/challenge-110/abigail/perl/ch-1.pl @@ -0,0 +1,36 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See ../README.md +# + +# +# Run as: perl ch-1.pl < input-file +# +# +# The examples show we should not take the specification as a specification; +# just a rough guideline. According to the specification, +# " +44 1148820341" fails the criteria not once, but twice: it contains +# a leading space (not allowed in the specification), and it has only a +# single space between the '+44' part and the rest, where the specification +# requires two. +# +# We therefore conclude the examples just contain random spaces, and we +# can completly ignore any white space in the input. +# + +while (<>) { + print if s/\s+//gr =~ /^ (?: \+\d{12} | \(\d{2}\)\d{10} | \d{14} )$/ax +} + + +__END__ |
