bory has asked for the wisdom of the Perl Monks concerning the following question:
foreach $key(keys(%FORM)){ open OLD, $file or die "Can't open $file:$!\n"; open NEW, ">$file.new" or die "Can't open temp file $file.new: + $!\n"; my $found =0; while (<OLD>) { if ($FORM{$key}==1) { $found =1; next; } print NEW; }} if ($found) { rename ("$file.new", $file) or die "Can't rename new $file: $ +!\n"; } else { print "I didn't find !\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: deleting a line from a text file
by rinceWind (Monsignor) on Sep 22, 2003 at 10:10 UTC | |
|
Re: deleting a line from a text file
by zby (Vicar) on Sep 22, 2003 at 09:59 UTC | |
|
Re: deleting a line from a text file
by CountZero (Bishop) on Sep 22, 2003 at 14:31 UTC | |
by cis (Initiate) on Mar 14, 2005 at 19:01 UTC |