blob: eee781f1c7ecf965da84180f0916f3ef101234de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
use Syntax::Construct qw{ // };
my $file = shift // '/usr/share/dict/british';
my %max = (0 => [""]);
open my $in, '<', $file or die $!;
WORD:
while (my $word = <$in>) {
chomp $word;
my $l = lc $word;
for my $i (2 .. length $word) {
next WORD if substr($l, $i - 2, 1) gt substr($l, $i - 1, 1);
}
if (length($word) > (keys %max)[0]) {
%max = (length $word => [$word]);
} elsif (length($word) == (keys %max)[0]) {
push @{ $max{ length $word } }, $word;
}
}
say for map @$_, values %max;
__END__
beefily
billowy
chikors
dikkops
Elmmott
|