NAME
IO::File::flock - extension of IO::File for flock
SYNOPSIS
use IO::File::flock;
or
use IO::File::flock qw(:flock);# export LOCK_*
# lock mode is automatically.
$fh = new IO::File "> file" or die($!);
# lock mode is LOCK_EX|LOCK_NB
$fh = new IO::File "file",'>','lock_nb' or die($!);
# set timeout 5 second
$fh = new IO::File "file",'>','lock_ex',5;
if($@ && $@ =~ /TIMEOUT/){
#timeout
}
$fh->lock_ex(); # if write mode (w or a or +> or > or >> or +<) then default
$fh->lock_sh(); # other then default
$fh->lock_un(); # unlock
$fh->lock_nb(); # get lock LOCK_EX|LOCK_NB
$fh->flock(LOCK_EX|LOCK_NB); # == $fh->lock_nb()
DESCRIPTION
IO::File::flock
inherits from IO::File
.
CONSTRUCTOR
METHODS
- open(FILENAME [,MODE [,LOCK_METHOD [,TIMEOUT]]]);
- flock(LOCK_MODE);
- lock_ex([TIMEOUT]);
- lock_sh([TIMEOUT]);
- lock_un([TIMEOUT]);
- lock_nb([TIMEOUT]);
AUTHOR
Shin Honda (makoto[at]cpan.org,makoto[at]cpan.jp)
copyright
Copyright (c) 2003- Shin Honda. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.