1File::Flock(3) User Contributed Perl Documentation File::Flock(3)
2
3
4
6 File::Flock - file locking with flock
7
9 use File::Flock;
10
11 lock($filename);
12
13 lock($filename, 'shared');
14
15 lock($filename, undef, 'nonblocking');
16
17 lock($filename, 'shared', 'nonblocking');
18
19 unlock($filename);
20
21 my $lock = new File::Flock '/somefile';
22
23 lock_rename($oldfilename, $newfilename)
24
26 Lock files using the flock() call. If the file to be locked does not
27 exist, then the file is created. If the file was created then it will
28 be removed when it is unlocked assuming it's still an empty file.
29
30 Locks can be created by new'ing a File::Flock object. Such locks are
31 automatically removed when the object goes out of scope. The unlock()
32 method may also be used.
33
34 lock_rename() is used to tell File::Flock when a file has been renamed
35 (and thus the internal locking data that is stored based on the
36 filename should be moved to a new name). unlock() the new name rather
37 than the original name.
38
40 File::Flock may be used/modified/distibuted on the same terms as perl
41 itself.
42
44 David Muir Sharnoff <muir@idiom.org>
45
46
47
48perl v5.12.0 2008-03-28 File::Flock(3)