我怎样才能检查一个文件句柄是否在Perl中打开? [英] How can I check if a filehandle is open in Perl?
本文介绍了我怎样才能检查一个文件句柄是否在Perl中打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想读取文件,所以不需要
flock
。open(FH,< $ fileName)或者死于$!\ n
#或者类似于
的东西close(FH)if(< FILE_IS_OPEN>);
解决方案
请参阅关于 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
Please see the answer regarding 这篇关于我怎样才能检查一个文件句柄是否在Perl中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! openhandle()
从 Scalar :: Util
一>。我原本写在这里的答案曾经是我们能做的最好的,但现在已经过时了。 flock
. open(FH, "<$fileName") or die "$!\n" if (<FILE_IS_NOT_ALREADY_OPEN>);
# or something like
close(FH) if (<FILE_IS_OPEN>);
解决方案 openhandle()
from Scalar::Util
. The answer I originally wrote here was once the best we could do, but it's now badly outdated.
查看全文