
Jasmine
Administrator
/ Moderator
Apr 11, 2000, 6:35 AM
Post #4 of 8
(489 views)
|
Basically flock is file locking. Once a file is opened and flocked, it can prevent another process from opening it and/or writing to it. Then, unlocking it would allow access to the file again. There is a millisecond that two files could be opening a file simultaneously before flock is invoked. The chances for this are very slim. To use flock, <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> open (FILE, ">counter.txt) or die "Couldn't open counter.txt $!"; flock FILE, 2; # do stuff to file close FILE or die "Couldn't close counter.txt $!"; flock FILE, 8; </pre><HR></BLOCKQUOTE> Basically the command is flock FILEHANDLE operation. 2 locks the file exclusively and 8 unlocks the file. Hope this helps! [This message has been edited by Jasmine (edited 04-11-2000).]
|