in reply to Re: (Ovid -flock) Re: File Use
in thread File Use

Then you're in luck. You want an exclusive lock on the file:
use Fcntl ':flock'; # import LOCK_* constants my $filename = "somefile.txt"; open FILE, ">>$filename" or die "Cannot open $filename for writing: $! +"; flock FILE, LOCK_EX or die "Cannot get exclusive lock on $filenam +e: $!";
Just be sure not to forget to unlock the file when done. Plus, my code above is for appending, which is what I suspect you want.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.