aboutsummaryrefslogtreecommitdiff
path: root/challenge-096/gugod/perl/ch-1.pl
blob: 7e7dfd792e6943ac01e3853785c407d456a57312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use v5.30;
use feature 'signatures';

sub reverse_words ($S) {
    return join " ", reverse split " ", $S;
}

## main
my @examples = (
    "The Weekly Challenge",
    "    Perl and   Raku are  part of the same family  ",
    "join reverse split \$S",
);

for my $S (@examples) {
    say "Input: $S";
    say "Output: " . reverse_words($S);
}