in reply to How do I determine if my script is already running?

I'm surprised noone mentioned my favorite:

#!/usr/bin/perl -w use strict; use Fcntl qw( LOCK_EX LOCK_NB ); flock(DATA,LOCK_EX|LOCK_NB) or die "This script ($0) is already running.\n"; #... __END__

I recently discovered that this works but isn't as pretty under Win32 since flock() is mandatory (with LOCK_EX meaning that no other handle can be open to that file, even within the same process and LOCK_SH meaning that no other handle can be open for writing to that file). So under Win32 the script just refuses to run. My current version of Perl doesn't even report an error message. O-:

        - tye (but my friends call me "Tye")