NAME
IO::LockedFile Class - supply object methods for locking files
SYNOPSIS
use IO::LockedFile;
# create new locked file object. $file will hold a file handle.
# if the file is already locked, the method will not return until the
# file is unlocked
my $file = new IO::LockedFile(">locked1.txt");
# when we close the file - it become unlocked.
$file->close();
# if we delete the object, the file is automatically unlocked and
# closed.
$file = undef;
DESCRIPTION
The IO::LockedFile class gives us the same interface of the IO::File class to files with the unique difference that those files are locked using the flock mechanism.
If during the running of the process, the process crashed - the file will be automatically unlocked. Actually - if the IO::LockedFile object goes out of scope, the file is automatically closed and unlocked.
CONSTRUCTOR
- new ( FILENAME [,MODE [,PERMS]] )
-
Creates a
IO::LockedFile
. If it receives any parameters, they are passed to the methodopen
; if the open fails, the object is destroyed. Otherwise, it is returned to the caller.
METHODS
- open( FILENAME [,MODE [,PERMS]] )
-
The file FILENAME will be opened as a locked file, and the object will be the file handle of that opened file. If the file that is opened is locked the method will not return until the file is unlocked. The parameters that should be provided are the same as the parameters that the method
open
ofIO::File
accepts. (like ">file.txt" for example). - close()
-
The file will be closed and unlocked. The method does not return anything.
- is_locked( FILENAME )
-
Will return true if the file is locked. Will return false otherwise.
AUTHOR
Rani Pinchuk, rani@cpan.org
COPYRIGHT
Copyright (c) 2001 EM-TECH (www.em-tech.net) & Rani Pinchuk. All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 170:
You forgot a '=back' before '=head1'