aboutsummaryrefslogtreecommitdiff
path: root/challenge-330/e-choroba/perl/ch-2.pl
blob: cccc0c51e949fb925124ea295de4fc8a8b4b7a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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';