I would look at the docs of the shell you're running under for the special variables associated with a PID. Rather than looking at Perl, see what your environment stores about the program. I'm betting there is an association somewhere between PID and command line, much as ps gives.