Second: how are you defining LOCK_EX? Is it possible that you are defining that locally somewhere and its value is not being passed to the function?
Third: Check all return calls!
The $! variable will have the error code that was generated by the failure. This may give you more information. However, if you don't have the or die construct in there, you may have a failure prior to your failure to flock the file.$filelog = "file.log"; open FILE, $filelog or die "Can't open $filelog: $!\n"; flock FILE, LOCK_EX or die "Can't write-lock $filelog: $!\n"; print FILE "$a:$b:$c\n" or die "Can't print to $filelog: $!\n"; close FILE or die "Can't print to $filelog: $!\n";
Also, notice that file.log is replaced by a variable rather than hardcoded. If you need to change this value in the future, you'll hate yourself for not doing this :)
And yes, closing a file dissolves the flock.
Cheers,
Ovid
In reply to Re: flock problem
by Ovid
in thread flock problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |