Reading the journal of brain d foy I noticed his filecounter entry where talks about using O_EXCL instead of flock. However I was under the impression O_EXCL is related to O_CREAT when the file exists, and should be used when you use rename() to get atomic operation at the filesystem level. In fact quoted fom perldoc -f open is the following.
In many systems the "O_EXCL" flag is available for
opening files in exclusive mode. This is not
locking: exclusiveness means here that if the file
already exists, sysopen() fails. The "O_EXCL"