To work around this, you can lock a semaphore file
instead of the actual file you are copying.
use strict;
use File::Copy;
use Fcntl ':flock'; # import LOCK_* constants
my $status_file = "/tmp/flocktest";
my $semaphore = "/tmp/flocktest.sem";
open(SEM,">$semaphore") || die "Can't open file";
flock(SEM, LOCK_EX) || die "Can't lock file";
copy($status_file,"/tmp/foo");
unlink $semaphore; # only on unix
close SEM;
|