本田 真 > IO-File-flock-0.10 > IO::File::flock

Download:
IO-File-flock-0.10.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.10   Source  

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_EX|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->flock(LOCK_EX|LOCK_NB); # get lock LOCK_EX|LOCK_NB

DESCRIPTION ^

IO::File::flock inherits from IO::File.

CONSTRUCTOR ^

new (FILENAME [,MODE [,LOCK_MODE [,TIMEOUT]]]);

creates a IO::File::flock.

METHODS ^

open(FILENAME [,MODE [,LOCK_MODE [,TIMEOUT]]]);

$fh->open(FILENAME,MODE) and $fh->flock(LOCK_MODE);

flock(LOCK_MODE);

flock($fh,$LOCK_MODE);

lock_ex();

$fh->flock(LOCK_EX);

lock_sh();

$fh->flock(LOCK_SH);

lock_un();

$fh->flock(LOCK_UN);

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.

SEE ALSO ^

flock, Fcntl, IO::File,

syntax highlighting: