There is also the (relatively) standard Unix utility lsof, which describes each of the open file descriptors for processes. This has the added benefit of identifying network sockets as well as true files.
the point of this post was to show how this could be done completly under perl, of course there are util for this sorta stuff. but its more fun and prolly faster to do it complety in perl :)