in reply to
LSOF Perl Implementation
I often find myself saying similar things in a quest to make my scripts as general and as portable as possible. If there were a Unix::lsof CPAN package available, I think you would be remiss in not using it. However, since there does not appear to be one, you have two options:
- Write your own package. This isn't really as difficult as you might think, and you could initially make it work on Linux (I'm assuming that you're using Linux) and port it to other operating systems later. For example, Solaris and FreeBSD probably wouldn't be difficult at all.
- Just use the pipe idea shown above. It has some very important strengths: it's simple, it works, and it gets the job down.
In a perfect world we'd always use a well-tested and highly portable CPAN module for things like this, and all of our Perl scripts would be portable to a wide variety of operating systems. However, it's important to sometimes forgo idealism in order to get the job done.