NAME
FlockDir - override perl flock() for network or portability purposes
SYNOPSIS
use File::FlockDir qw (open close flock);
open (FH, ">$path");
flock(FH, 2);
close FH;
DESCRIPTION
A flock module for Windows9x and other systems lacking a good perl flock() function (not platform specific)
Usage:
use File::FlockDir qw (open close flock);
OR (careful)
use File::FlockDir qw (GLOBAL_open GLOBAL_close GLOBAL_flock);
Rationale: flock on Win95/98 is badly broken but perl code needs to be portable. One way to do this is to override perl's open(), flock(), and close(). We then get an absolute file specification for all opened files and and use it in a hash to create a unique lock for the file using the File::LockDir module from Perl Cookbook, by Christiansen and Torkington (O'Reilly, 1998). This module may be included in the CPAN distribution but belongs to those authors. New code is deliberately kept at a minimum. As with nflock(), this will allow flock() to work over a network (usually).
KNOWN PROBLEMS AND LIMITATIONS
May be slow compared to unix flock().
Abnormal termination may leave File::LockDir entries still on the drive. This means the directory locks set by File::LockDir will have to be removed after a system crash to prevent the module from assuming that files locked at the time of the crash are still locked later.
Since the implementation creates a subdirectory in the directory containing the file that you flock(), you must have permission to create a directory where the file is located in order to flock() that file over the network.
CREDITS
Perl Cookbook, by Tom Christiansen and Nathan Torkington.
This module is an extension of Perl Cookbook's nflock(), in chapter 7, section 21 (7.21, pp 264-266).
AUTHOR
William Herrera <wherrera@lynxview.com>