in reply to self detecting script

There's a whole slew of modules on CPAN dealing with this: File::Pid, Proc::PidUtil, Proc::Pidfile, Proc::PID::File.