From fade7f9cc20b4a6bd64313aa3f07ac2e40c10a5e Mon Sep 17 00:00:00 2001 From: Abigail Date: Mon, 26 Apr 2021 17:24:16 +0200 Subject: Perl solution for week 110, part 1 --- challenge-110/abigail/README.md | 1 + challenge-110/abigail/perl/ch-1.pl | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 challenge-110/abigail/perl/ch-1.pl 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__ -- cgit