There's a Proc::Pidfile module just to do this for you.
In reply to Re: Abort if instance already running? by kyle in thread Abort if instance already running? by pileofrogs