use strict; use Fcntl qw(:DEFAULT); my $semaphore = 'c:/test.txt'; sysopen (SEMAPHORE, $semaphore, O_WRONLY | O_EXCL | O_CREAT) or &busy; print "There can be only one!"; sleep 20; close SEMAPHORE; unlink $semaphore or die "Can't unlink $semaphore $!\n"; exit; sub busy { print "Sorry, I am busy!"; exit; } #### C:\>type flock.pl use Fcntl qw(:flock); print "This is $^O\n"; open FILE, ">>test.txt" or die "Oops $!\n"; flock FILE, LOCK_EX or die "Can't flock $!\n"; close FILE; C:\>perl flock.pl This is MSWin32 flock() unimplemented on this platform at flock.pl line 6. C:\>