I have couple things to add to
what merlyn said, regarding this comment in your description:
this script is for use exclusively under Unix, or Unix like, operating systems (if the system command ps -eaf could be rewritten in pure Perl, then the OS restriction could be lifted)
Unfortunately, one of the issues that differ significantly across versions of unix and unix-like operating systems is the behavior of "ps". In particular, the options you use in this script will work on any "SysV" style of unix (e.g. Solaris), and might work on linux (if you're using linux, you know better than me), but it won't work on any BSD style (e.g. (free|open|net)bsd, or the bsd-based macosx), because the latter uses a completely different set of option flags.
It turns out there are a couple ways around this:
- Have some logic that looks at $^O and sets option flags for "ps" accordingly (update: unless you do this very carefully, you may still have problems because the output formats will be very different for BSD vs. SysV), or
- use Unix::Process, which allows you to get just the information you want from "/bin/ps", by way of the abbreviations assigned to the different possible output fields ("pid", "ppid", "vsz", etc). It still runs /bin/ps to do its work, and the different versions of "ps" are not 100% consistent in the field names (e.g. Solaris "ps" uses "comm" and "args" where BSD uses just "command"), but several important names are common to both versions -- whereas the command-line options are not. So you still might need to do different stuff depending on the value of $^O, but some things are more likely to be the same for all unixen.