aboutsummaryrefslogtreecommitdiff
path: root/challenge-161
diff options
context:
space:
mode:
authorJörg Sommrey <28217714+jo-37@users.noreply.github.com>2022-04-19 15:46:41 +0200
committerJörg Sommrey <28217714+jo-37@users.noreply.github.com>2022-04-22 16:22:55 +0200
commit0d5b21e8c972d047501d25fd697b36030eb98a92 (patch)
tree68d3c3ba921745b871ceb5a52dcf01b47f04f322 /challenge-161
parent8442850a27b68360e885f80a906b6d71fdf1717e (diff)
downloadperlweeklychallenge-club-0d5b21e8c972d047501d25fd697b36030eb98a92.tar.gz
perlweeklychallenge-club-0d5b21e8c972d047501d25fd697b36030eb98a92.tar.bz2
perlweeklychallenge-club-0d5b21e8c972d047501d25fd697b36030eb98a92.zip
Solution to task 1
Diffstat (limited to 'challenge-161')
-rwxr-xr-xchallenge-161/jo-37/perl/ch-1.pl18
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 //;
+ }
+};