use POSIX; use File::lockf; $status = File::lockf::lock ($args); # replace $args as appropriate. if ($status) { # Uh oh, non zero value returned. # Lets use POSIX's errstr() to find out what happened $error_string = strerror ($status); die "Uh oh, lockf returned '$error_string'"; }