The Perl FAQ recommends not using code like that or in their words "a common bit of code NOT TO USE is this:
sleep(3) while -e "file.lock"; # PLEASE DO NOT USE
open(LCK, "> file.lock"); # THIS BROKEN CODE
Check out
http://www.perl.com/..._I_just_open_FH_file for the explanation.
The question above that states:
Some versions of flock() can't lock files over a network (e.g. on NFS file systems), so you'd need to force the use of fcntl(2) 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.
For more information on file locking, see also perlopentut if you have it (new for 5.006).
Take care,
RJ
http://LetsGoPens.com/