diff options
| -rwxr-xr-x | challenge-330/e-choroba/perl/ch-1.pl | 17 | ||||
| -rwxr-xr-x | challenge-330/e-choroba/perl/ch-2.pl | 14 |
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'; |
