in reply to flock problem

First: what is the error message you are getting when the flock fails?

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!

$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";
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.

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