in reply to Re: flock problem
in thread flock problem

The bareword function call may not be a problem, if login.pl has been required before the code we see. I always use the parenthesis on function calls, though, just to make things clear.

I prefer to use the symbolic constants from Fcntl rather than the numbers, for the lock type argument to flock. It's just safer:

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;
That'll clobber file.log, by the way. (if you don't want to do that, see mikfire's post here.)

The code for login.pl is similar, except it's LOCK_SH there.