#! perl -lw use strict; use Fcntl ':flock'; open my $fh, "<", "whatever" or die $!; flock $fh, LOCK_EX; flock $fh, LOCK_EX;