... open(PIDFILE,">>$pidFile") or die "Cannot open pidfile, $pidFile: $!\n"; if (! &lock(*PIDFILE) ) { print "\n\tCannot obtain exclusive lock on $pidFile\n", "\tThere must be another instance of this\n", "\tprogram running. Exiting.\n\n"; exit; } # GOT LOCK my @arr = (); open(PIDFILE,">$pidFile"); print PIDFILE "$$\n"; ...