aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karelas <karjala@cpan.org>2025-07-17 23:22:10 +0300
committerAlexander Karelas <karjala@cpan.org>2025-07-17 23:22:10 +0300
commit75bcc9af80058b7fc8841f046ba71b58f039b34a (patch)
tree53e47864f91747f0940da19503486c3dca563a03
parentc426fab2721595210e8e2ad3cef39a501b938e30 (diff)
downloadperlweeklychallenge-club-75bcc9af80058b7fc8841f046ba71b58f039b34a.tar.gz
perlweeklychallenge-club-75bcc9af80058b7fc8841f046ba71b58f039b34a.tar.bz2
perlweeklychallenge-club-75bcc9af80058b7fc8841f046ba71b58f039b34a.zip
solution to challenge 330
-rwxr-xr-xchallenge-330/alexander-karelas/perl/ch-2.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-330/alexander-karelas/perl/ch-2.pl b/challenge-330/alexander-karelas/perl/ch-2.pl
new file mode 100755
index 0000000000..a6df47e7b0
--- /dev/null
+++ b/challenge-330/alexander-karelas/perl/ch-2.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+use v5.40;
+
+use Test2::V0;
+
+sub title_capital ($string) {
+ my @words = split / /, $string;
+ foreach (@words) {
+ $_ = lc;
+ $_ = ucfirst if length > 2;
+ }
+ return join ' ', @words;
+}
+
+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';
+
+done_testing;