aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-07-15 18:23:03 +0100
committerGitHub <noreply@github.com>2025-07-15 18:23:03 +0100
commit9180a7cac96bbade5e958d93c3a2750997f7792e (patch)
tree25d6a2c3e2450e93e5e1af6054031a0eff09018a
parent1f7a37e4c0d69ad579f71fa1ee53e0d34e8c4525 (diff)
parent34cb0e39c0844822f8da3cae9b101fbd161f3768 (diff)
downloadperlweeklychallenge-club-9180a7cac96bbade5e958d93c3a2750997f7792e.tar.gz
perlweeklychallenge-club-9180a7cac96bbade5e958d93c3a2750997f7792e.tar.bz2
perlweeklychallenge-club-9180a7cac96bbade5e958d93c3a2750997f7792e.zip
Merge pull request #12356 from mahnkong/challenge-330
Challenge 330
-rw-r--r--challenge-330/mahnkong/perl/ch-1.pl14
-rw-r--r--challenge-330/mahnkong/perl/ch-2.pl17
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-330/mahnkong/perl/ch-1.pl b/challenge-330/mahnkong/perl/ch-1.pl
new file mode 100644
index 0000000000..8063b02757
--- /dev/null
+++ b/challenge-330/mahnkong/perl/ch-1.pl
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+use feature 'signatures';
+use Test::More 'no_plan';
+
+sub run($str) {
+ $str =~ s/\D?\d// while $str =~ /\D?\d/;
+ return $str;
+}
+
+is(run('cab12'), 'c', "Example 1");
+is(run('xy99'), '', "Example 2");
+is(run('pa1erl'), 'perl', "Example 3");
+is(run('ab132x'), 'x', "Example 4");
diff --git a/challenge-330/mahnkong/perl/ch-2.pl b/challenge-330/mahnkong/perl/ch-2.pl
new file mode 100644
index 0000000000..904af50abf
--- /dev/null
+++ b/challenge-330/mahnkong/perl/ch-2.pl
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+use feature 'signatures';
+use Test::More 'no_plan';
+
+sub run($string) {
+ my @result;
+ while ($string =~ /(\S+)/g) {
+ push @result, lc($1);
+ $result[-1] = ucfirst($result[-1]) if length($result[-1]) > 2;
+ }
+ return join(" ", @result);
+}
+
+is(run("PERL IS gREAT"), "Perl is Great", "Example 1");
+is(run("THE weekly challenge"), "The Weekly Challenge", "Example 2");
+is(run("YoU ARE A stAR"), "You Are a Star", "Example 3");