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.
In reply to Re: Finding duplicate keys
by dga
in thread Finding duplicate keys
by Wally Hartshorn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |