I'm using this code to remove all duplicates, but I have a need to remove only specific duplicates and leave all others untouched.
In my case if the line matches /^\s+INDEX 00 \d\d:\d\d:\d\d$/
then keep each unique first line, but delete duplicates, and keep all lines that don't match the regex.
tie my @lines, 'Tie::File', $fn or die "could not tie file: $!";
my %seen;
@lines = grep(!$seen{$_}++, @lines);
untie @lines;