diff options
| author | Andreas Mahnke <andreas.mahnke@leuphana.de> | 2025-07-15 15:52:15 +0200 |
|---|---|---|
| committer | Andreas Mahnke <andreas.mahnke@leuphana.de> | 2025-07-15 15:52:15 +0200 |
| commit | 34cb0e39c0844822f8da3cae9b101fbd161f3768 (patch) | |
| tree | de90c513308fb429851d038b1aaf881aebc7e325 | |
| parent | 6345c73edaafe1c1252e99cf8991c8fc27890445 (diff) | |
| download | perlweeklychallenge-club-34cb0e39c0844822f8da3cae9b101fbd161f3768.tar.gz perlweeklychallenge-club-34cb0e39c0844822f8da3cae9b101fbd161f3768.tar.bz2 perlweeklychallenge-club-34cb0e39c0844822f8da3cae9b101fbd161f3768.zip | |
Challenge 330
| -rw-r--r-- | challenge-330/mahnkong/perl/ch-1.pl | 14 | ||||
| -rw-r--r-- | challenge-330/mahnkong/perl/ch-2.pl | 17 |
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"); |
