in reply to Re: Separate duplicate and unique records
in thread Separate duplicate and unique records

A dup needs printed to the file each time it appears.

(Untested)

... while (<IN>) { $seen{$_}++; } foreach my $id (sort keys %seen) { if ( $seen{$id} == 1 ) { print UNQ "$id\n"; } else { print DUP "$id\n" foreach 1..$seen{$id}; } } ...