How can I check if a filehandle is open in Perl?
Posted
by matt
on Stack Overflow
See other posts from Stack Overflow
or by matt
Published on 2009-02-06T13:04:36Z
Indexed on
2010/04/11
1:13 UTC
Read the original article
Hit count: 333
Is there a way to check if a file is already open in Perl?
I want to have a read file access, so don't require flock
.
open(FH, "<$fileName") or die "$!\n" if (<FILE_IS_NOT_ALREADY_OPEN>);
# or something like
close(FH) if (<FILE_IS_OPEN>);
© Stack Overflow or respective owner