home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  



Establishes or removes a lock on a file opened with filehandle . This function calls one of the Unix functions flock , lockf , or the locking capabilities of fcntl , whichever your system supports. If none of these functions exist on your system, flock will produce a fatal error.

operation is the type of locking function to perform. The number by each operation name is the argument that Perl's flock takes by default. You may also use the operation names if you explicitly import them from the Fcntl module with use Fcntl ":flock" .


Establishes a shared lock on the file (read lock).


Establishes an exclusive lock on the file (write lock).


Removes a lock from the file.


Prevents flock from blocking while trying to establish a lock with LOCK_SH or LOCK_EX and instructs it to return immediately. LOCK_NB must be or ed with the other operation as an expression for the operation argument, i.e., (LOCK_EX | LOCK_NB) .