aboutsummaryrefslogtreecommitdiff
path: root/challenge-096/polettix/perl/ch-1.pl
blob: ca9b2bb55f16e1cf3750a98dbf06165a4be0aaf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env perl
use 5.024;
use warnings;
use experimental qw< postderef signatures >;
no warnings qw< experimental::postderef experimental::signatures >;

sub reverse_words ($S) {
   join(' ', reverse split m{\s+}mxs, $S) =~ s{\s+\z}{}rmxs;
}

my $input = join(' ', @ARGV)
   || '    Perl and   Raku are  part of the same family  ';
say '<', reverse_words($input), '>';