in reply to flock with FileHandle.pm?
If this bothers you, you can just add the following:flock($fh, $mode) or die "Cannot flock file in $mode: $!";
and now you can just call:package FileHandle; use Carp; sub lock { my $self = shift; flock($self, 8) or confess("Cannot lock file: $!"); }
Note that I did not create an unlock method. That is intentional. Files should never be unlocked. Instead you close or drop the filehandle, and they will be unlocked for you by the OS.$fh->lock();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 1: flock with FileHandle.pm?
by DBX (Pilgrim) on Aug 24, 2001 at 11:29 UTC | |
by tilly (Archbishop) on Aug 24, 2001 at 21:34 UTC | |
by DBX (Pilgrim) on Aug 24, 2001 at 21:50 UTC |