From 75bcc9af80058b7fc8841f046ba71b58f039b34a Mon Sep 17 00:00:00 2001 From: Alexander Karelas Date: Thu, 17 Jul 2025 23:22:10 +0300 Subject: solution to challenge 330 --- challenge-330/alexander-karelas/perl/ch-2.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 challenge-330/alexander-karelas/perl/ch-2.pl 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; -- cgit