#!/usr/bin/perl use strict; use warnings; my %max; my %seen; open(my $fh, '<', '2of12inf.txt') or die "Unable to open '2of12inf.txt' for reading: $!\n"; while (<$fh>) { chomp; $_ = lc($_); tr/a-z//cd; next if ! $_ || length($_) > 8 || $seen{$_}++; print "$_\n"; my %uniq; ++$uniq{$_} for split //; for (keys %uniq) { $max{$_} = $uniq{$_} if ! $max{$_} || $uniq{$_} > $max{$_}; } } for my $l (sort keys %max) { warn "$l:$max{$l}\n"; }