in reply to Finding duplicate keys

Hows this?

my %keys; while(<>) { chop; $keys{$_}++; } foreach my $k ( keys %keys ) { print "$k: $keys{$k}\n"; }

This will count the times a particular input line was seen and then print them out in no apperent order. A sort could be added to the foreach if you would like an order, like, for example sort { $keys{$b} <=> $keys{$a} } ... if you wanted them in descending order by count of duplicates.

Update: Also note that this stores only the comparison data and makes only a single pass through the files.