aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-08-19 01:00:30 +0100
committerGitHub <noreply@github.com>2024-08-19 01:00:30 +0100
commit0b972907c5669104dbe239f2e1864fd3b4fdaa0d (patch)
tree452ab1edad8d8811ead25882b8b968fbad6f8ec6
parent4b02d713baf87044802a9324c8da347b55c4a067 (diff)
parent8c53f0f4069325edab6461f4418b72e7a1af9e24 (diff)
downloadperlweeklychallenge-club-0b972907c5669104dbe239f2e1864fd3b4fdaa0d.tar.gz
perlweeklychallenge-club-0b972907c5669104dbe239f2e1864fd3b4fdaa0d.tar.bz2
perlweeklychallenge-club-0b972907c5669104dbe239f2e1864fd3b4fdaa0d.zip
Merge pull request #10646 from MatthiasMuth/muthm-282
Challenge 282 Task 1 and 2 solutions in Perl by Matthias Muth (cosmetic changes)
-rwxr-xr-xchallenge-282/matthias-muth/perl/ch-1.pl7
-rwxr-xr-xchallenge-282/matthias-muth/perl/ch-2.pl2
2 files changed, 2 insertions, 7 deletions
diff --git a/challenge-282/matthias-muth/perl/ch-1.pl b/challenge-282/matthias-muth/perl/ch-1.pl
index fccdcaa6be..de9c0f6acf 100755
--- a/challenge-282/matthias-muth/perl/ch-1.pl
+++ b/challenge-282/matthias-muth/perl/ch-1.pl
@@ -10,12 +10,8 @@
use v5.36;
-sub good_integer_1( $int ) {
- return $int =~ / (.)\g{-1}\g{-1} /x ? $& : -1;
-}
-
sub good_integer( $int ) {
- return $int =~ / (?: ^ | (.)(?!\g{-1}) ) ( (.)\g{-1}\g{-1} ) (?!\g{-1}) /x ? $2 : -1;
+ return $int =~ / (?: ^ | (\d)(?!\g{-1}) ) ( (\d)\g{-1}\g{-1} ) (?!\g{-1}) /x ? $2 : -1;
}
use Test2::V0 qw( -no_srand );
@@ -23,7 +19,6 @@ use Test2::V0 qw( -no_srand );
my $sub_name = "good_integer";
for my $sub ( sort grep /^${sub_name}/, keys %:: ) {
note "Testing $sub:";
-
no strict 'refs';
is $sub->( 12344456 ), 444,
'Example 1: good_integer( 12344456 ) == 444';
diff --git a/challenge-282/matthias-muth/perl/ch-2.pl b/challenge-282/matthias-muth/perl/ch-2.pl
index da0a03c4c6..11b66ea762 100755
--- a/challenge-282/matthias-muth/perl/ch-2.pl
+++ b/challenge-282/matthias-muth/perl/ch-2.pl
@@ -11,7 +11,7 @@
use v5.36;
sub changing_keys( $str ) {
- return scalar( () = $str =~ /(.)(?=.)(?=.)(?!\g1)/ig );
+ return scalar( () = $str =~ /(.)(?=.)(?!\g1)/ig );
}
use Test2::V0 qw( -no_srand );