in reply to deleting a line from a text file
What I changed: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{$_}==1) { $found =1; next; } print NEW; } } close NEW; close OLD; if ($found) { rename ("$file.new", $file) or die "Can't rename new $file: $ +!\n"; } else { print "I didn't find !\n"; }
You could look at File::Atomic if you run this concurrently.
|
|---|