[vox-tech] Perl question: file handling
Rod Roark
vox-tech@lists.lugod.org
Mon, 24 Jun 2002 13:54:31 -0700
I'm looking at some Perl code (not mine) that does this=20
(simplified for clarity):
open(INFILE, "<$filename");
flock INFILE, LOCK_EX;
open(OUTFILE, ">$tempname");
flock OUTFILE, LOCK_EX;
...
(read from INFILE, change stuff, write to OUTFILE)
...
rename $tempname, $filename;
flock OUTFILE, LOCK_UN;
close(OUTFILE);
flock INFILE, LOCK_UN;
close(INFILE);
Notice that it's renaming/deleting files that are open and
locked. Is this as insane as I think it is?
Thanks,
-- Rod
http://www.sunsetsystems.com/