How do you check if a file is open using Perl?
POSIX does not provide any way to do this. Therefore, no portable solution is possible given the current portable O/S interface available.
You’d have to craft some higher level approach that provides a single point of access for the opening bits. It’s like with lock files.