One potential problem that hasn't been mentioned yet, is that the process may die during the print OUTFILE action, causing some data at the end of the file to be lost. I usually write to a temporary file then rename this temporary file to replace the original file. Renaming is atomic on every system that I'm aware of.
For example:
# At this point I have created some sort of lock to ensure # nobody else is going to read or write $infile_name while (<INFILE>) { # Using read instead of <INFILE> would be more e +fficient print TEMPFILE; } close TEMPFILE rename $temp_filename, $infile_name or die # Remove the lock here
In reply to Re: flock issue
by tomhukins
in thread flock issue
by airman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |