aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-110/luca-ferrari/raku/ch-1.p614
1 files changed, 10 insertions, 4 deletions
diff --git a/challenge-110/luca-ferrari/raku/ch-1.p6 b/challenge-110/luca-ferrari/raku/ch-1.p6
index 2eee9c781f..d31e9fa671 100644
--- a/challenge-110/luca-ferrari/raku/ch-1.p6
+++ b/challenge-110/luca-ferrari/raku/ch-1.p6
@@ -2,9 +2,15 @@
sub MAIN( Str $file-name = 'phone.txt' ) {
- my @regexps = rx / ^ \s* <[+]> \d ** 2 \s+ \d ** 10 $ /
- , rx / ^ \s* <[(]> \d ** 2 <[)]> \s+ \d ** 10 $ /
- , rx / ^ \s* \d ** 4 \s+ \d ** 10 $ /;
+ my $phone-regexp = rx/ \d ** 10 /;
+ my $prefix-regexp = rx/
+ <[+]> \d ** 2
+ || <[(]> \d ** 2 <[)]>
+ || \d ** 4
+ /;
- say $_ if $_ ~~ any @regexps for $file-name.IO.lines;
+
+ my $phone-rx = rx / ^ \s* $prefix-regexp \s+ $phone-regexp $ /;
+
+ $_.say if $_ ~~ $phone-rx for $file-name.IO.lines;
}