在 perl 中使用 -d 测试运算符 [英] Using the -d test operator in perl
本文介绍了在 perl 中使用 -d 测试运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在查看某人的旧代码,发现了以下语句:
$tmpStr = "/some/file/location/";如果(-d $tmpStr){printf("1");}别的{printf("2");}
我对 -d
的作用感到困惑...有什么帮助吗?
解决方案
-d
如果以下字符串是目录,则返回 true.
参见 perlfunc 中的 -X
.>
I'm going through someone's old code and I came across this statement:
$tmpStr = "/some/file/location/";
if(-d $tmpStr){
printf("1");
}else{
printf("2");
}
I'm confused about what the -d
does... any help?
解决方案
-d
returns true if the following string is a directory.
See -X
in perlfunc.
这篇关于在 perl 中使用 -d 测试运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文