aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-07-15 10:43:19 +0100
committerGitHub <noreply@github.com>2025-07-15 10:43:19 +0100
commit2041bdc4023d06e6d1537d8f73ab6a35218130d2 (patch)
tree18ef9bf677ff2122d83e3d62bf9f15df7ebc4e3a
parent2fde156973e49f23a262ef454aa4f4e6031cfc98 (diff)
parent54a6199834d0e9a6d31817db491280776fa5893c (diff)
downloadperlweeklychallenge-club-2041bdc4023d06e6d1537d8f73ab6a35218130d2.tar.gz
perlweeklychallenge-club-2041bdc4023d06e6d1537d8f73ab6a35218130d2.tar.bz2
perlweeklychallenge-club-2041bdc4023d06e6d1537d8f73ab6a35218130d2.zip
Merge pull request #12341 from choroba/ech330
Add solutions to 330: Clear Digits & Title Capital by E. Choroba
-rwxr-xr-xchallenge-330/e-choroba/perl/ch-1.pl17
-rwxr-xr-xchallenge-330/e-choroba/perl/ch-2.pl14
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-330/e-choroba/perl/ch-1.pl b/challenge-330/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..cb9bad898b
--- /dev/null
+++ b/challenge-330/e-choroba/perl/ch-1.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub clear_digits($str) {
+ 1 while $str =~ s/\D\d//;
+ return $str
+}
+
+use Test::More tests => 3 + 1;
+
+is clear_digits('cab12'), 'c', 'Example 1';
+is clear_digits('xy99'), "", 'Example 2';
+is clear_digits('pa1erl'), 'perl', 'Example 3';
+
+is clear_digits('a12b'), '2b', 'Unremovable digit';
diff --git a/challenge-330/e-choroba/perl/ch-2.pl b/challenge-330/e-choroba/perl/ch-2.pl
new file mode 100755
index 0000000000..cccc0c51e9
--- /dev/null
+++ b/challenge-330/e-choroba/perl/ch-2.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub title_capital($str) {
+ join ' ', map length > 2 ? ucfirst lc : lc, split / /, $str
+}
+
+use Test::More tests => 3;
+
+is title_capital('PERL IS gREAT'), 'Perl is Great', 'Example 1';
+is title_capital('THE weekly challenge'), 'The Weekly Challenge', 'Example 2';
+is title_capital('YoU ARE A stAR'), 'You Are a Star', 'Example 3';