in reply to find duplicates and write to file
my %seen; while (<>) { my ($key) = /^(\S+)/; push @{ $seen{$key} }, $_; } for my $key (keys(%seen)) { my $vals = $seen{$key}; print @$vals if @$vals > 1; } [download]