NAME
PerlIO::flock - Easy flock() interface
SYNOPSIS
open my $in,  '< :flock', $file; # shared lock
open my $out, '+<:flock', $file; # exclusive lock
binmode($fh, ':flock(blocking)');
binmode($fh, ':flock(non-blocking)');DESCRIPTION
The :flock layer provides an interface to flock().
It tries to lock the filehandle with flock() according to the open mode. That is, if a file is opened for writing, :flock attempts exclusive lock (using LOCK_EX). Otherwise, it attempts shared lock (using LOCK_SH).
It waits until the lock is granted. If an argument non-blocking (or LOCK_NB) is suplied, the call of open() (or binmode()) fails when the lock cannot be granted.
EXAMPLE
# tries shared lock, or waits until the lock is granted
open IN, "<:flock", $file;
open IN, "<:flock(blocking)", $file;     # ditto.
# tries shared lock, or returns undef
open IN, "<:flock(non-blocking)", $file; 
open IN, "<:flock(LOCK_NB)", $file;      # ditto.SEE ALSO
AUTHOR
Goro Fuji <gfuji (at) cpan.org>
LICENCE AND COPYRIGHT
Copyright (c) 2008, Goro Fuji <gfuji (at) cpan.org>. Some rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.