use Fcntl ':flock' ; open ONE, ">> C:\\temp\\RTEOlock.log" or die $!; my $lck = eval {flock ONE, LOCK_EX | LOCK_NB}; die 'flock not supported! ', $@ if $@; if ($lck) { # The other script is not running code here } else { # The other script is running code here }