diff options
| author | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2022-04-19 15:46:41 +0200 |
|---|---|---|
| committer | Jörg Sommrey <28217714+jo-37@users.noreply.github.com> | 2022-04-22 16:22:55 +0200 |
| commit | 0d5b21e8c972d047501d25fd697b36030eb98a92 (patch) | |
| tree | 68d3c3ba921745b871ceb5a52dcf01b47f04f322 /challenge-161 | |
| parent | 8442850a27b68360e885f80a906b6d71fdf1717e (diff) | |
| download | perlweeklychallenge-club-0d5b21e8c972d047501d25fd697b36030eb98a92.tar.gz perlweeklychallenge-club-0d5b21e8c972d047501d25fd697b36030eb98a92.tar.bz2 perlweeklychallenge-club-0d5b21e8c972d047501d25fd697b36030eb98a92.zip | |
Solution to task 1
Diffstat (limited to 'challenge-161')
| -rwxr-xr-x | challenge-161/jo-37/perl/ch-1.pl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-161/jo-37/perl/ch-1.pl b/challenge-161/jo-37/perl/ch-1.pl new file mode 100755 index 0000000000..1e118c43db --- /dev/null +++ b/challenge-161/jo-37/perl/ch-1.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl + +use v5.16; +use warnings; +use constant DICT => '../../../data/dictionary.txt'; +use List::Util 'reduce'; +use Syntax::Keyword::Gather; + +# Specify the name of a dictionary as program argument or use the +# provided dictionary otherwise. +$ARGV[0] = DICT unless @ARGV; + +say for sort {length($b) <=> length($a) || $a cmp $b} gather { + while (<>) { + chomp; + take $_ if reduce {$a && $a le $b ? $b : ''} split //; + } +}; |
