[plug] perl flock question

Mark Haselden levsky at neubauten.iinet.net.au
Wed Nov 6 13:35:50 WST 2002


On Wed, Nov 06, 2002 at 01:33:00PM +0800, Patrick Tehvand wrote:
> Hi all,
> 
> is this the correct usage of flock?
> 
> open(FILE,">$file");
> flock (COUNTER, 2);
> print FILE "$in{stuff}|$in{otherstuff}";
> flock (FILE, 8);
> close(FILE);
> 

You mean flock(FILE, 2)?  Otherwise yes.

If you use Fcntl qw(:flock), you can get
LOCK_EX, LOCK_UN imported into your local namespace which
makes it an awful lot more readable.

Cheers

Mark


-- 
Being a Unix system administrator is like being a tech in a biological 
warfare laboratory, except that none of the substances are labeled 
consistently, any of the compounds are just as likely to kill you by 
themselves as they are when mixed with one another, and it is never 
clear what distinction is made between a catastrophic failure in the lab 
and a successful test in the field. 

Michael Tiemann 



More information about the plug mailing list