Your code suggests that you want to make the changes "in-place". You could do it all in a one-liner as follows: perl -i.bak -ne 'print unless /pattern/ and $i++' file Enjoy your vacation. :-)my $i = 0; while (<FILE>) { $temp .= $_ unless /$heading_to_print/ and $i++; }
--
John.
In reply to Re: Replacing all but one duplicate lines
by jmcnamara
in thread Replacing all but one duplicate lines
by johnirl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |