本文介绍了“-s"是什么意思?在 Perl 中 if 块做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的代码块:
I have a block of code as such:
if ( ! -s $fh ) {
...more code
}
我只需要知道-s"是什么意思!
I just need to know what the "-s" means!
推荐答案
-s $fh
检查 $fh
的文件大小,所以 !-s $fh
测试文件大小是否长度为零(或者没有这样的文件).
-s $fh
checks file size of $fh
, so ! -s $fh
tests if file size has length zero (or there is no such file).
$fh
可以是文件名或文件句柄(检查 perldoc -f -X).
$fh
can be file name, or file handle (check perldoc -f -X).
请注意,这与 -z $fh
不同,因为它不会为不存在的文件返回 true.
Note that this is not the same as -z $fh
, as it won't return true for non existing files.
这篇关于“-s"是什么意思?在 Perl 中 if 块做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!