in reply to Finding out by one process a filename opened by another process.
If you have the PID, then the shell command lsof -p will list all files opened by that PID. Also, lsof <filename> will list the processes that have opened a specific file. Etc.
lsof is a very powerful command, and it requires root access, so you'll have to provide password-less sudo access for the user executing the script in order for this solution to work.
In Section
Seekers of Perl Wisdom