in reply to Re: flock problem
in thread flock problem
I prefer to use the symbolic constants from Fcntl rather than the numbers, for the lock type argument to flock. It's just safer:
That'll clobber file.log, by the way. (if you don't want to do that, see mikfire's post here.)use Fcntl qw(:DEFAULT :flock); # from the Perl Cookbook open(FILE, ">file.log") or die "Can't open and truncate file: $!"; flock(FILE, LOCK_EX) or die "Can't obtain exclusive lock: $!"; print FILE "$a:$b:$c\n"; close FILE;
The code for login.pl is similar, except it's LOCK_SH there.
|
|---|