I am working on a simple perl module of subroutines for developers on a development team to use. The goal is to make a lot of different perl scripts written by several different people do a lot of things similarly. One of the things we want all of our scripts to do is write a pid file. So in my library I'm writing a subroutine to get the pid of the script and write a file named "<process name>.pid", which will contain the pid of the script. Getting the pid is easy enough I think (just call getppid), but what about getting the name of the script that's running? Is there a good way to do this other than parse the output of "ps ax|grep $pid"?