in reply to Count of patterns in a file without knowing pattern in advance
my %seen; while (<$FILE>) { chomp; ++$seen{$_}; } for my $string (keys %seen) { print "$string encountered $seen{$string} time(s).\n"; } [download]