johnirl has asked for the wisdom of the Perl Monks concerning the following question:
quick question I have a script that reads in a file and removes a specific line. However what I want it to do is remove all occurances of the specific line except for the first one
Any ideas on how I could do this. I know this is a RDFM question but I am going on vacation today and I need to get it done quick
open FILE, "<" . $filename or die "Couldn't open file " . $fil +ename . " for reading"; while (<FILE>){ $temp .= $_ unless /$heading_to_print/; } close FILE; open FILE, ">" . $filename or die "Couldn't open file " . $fil +ename . " for writing"; print FILE $temp;
Thanks in advance quys
JohnIrl
Sum day soon I'Il lern how 2 spelI (r tYpe)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing all but one duplicate lines
by demerphq (Chancellor) on Jul 19, 2002 at 12:41 UTC | |
|
Re: Replacing all but one duplicate lines
by jmcnamara (Monsignor) on Jul 19, 2002 at 13:03 UTC | |
|
Re: Replacing all but one duplicate lines
by Abigail-II (Bishop) on Jul 19, 2002 at 16:01 UTC | |
by demerphq (Chancellor) on Jul 19, 2002 at 16:24 UTC |