flock
function (see the perlfunc manpage for details) will call flock
if that exists,
fcntl
if it doesn't, and lockf
if neither of the
two previous system calls exists. On some systems, it may even use native
locking. Some gotchas with Perl's flock:
lockf
does not provide shared locking, and requires that the
filehandle be open for writing (or appending, or read/writing).
flock
can't lock files over a network (e.g. on
NFS file systems), so you'd need to force the use of fcntl
when you build Perl (see the flock entry of
the perlfunc manpage, and the INSTALL
file in the source distribution for information on building Perl to do
this).
flock
can't lock network files.