如何查看Perl中是否存在目录?
发布时间:2020-12-15 21:28:03 所属栏目:大数据 来源:网络整理
导读:要在使用文件之前查看文件是否存在,我们可以使用: if (-e "filename.cgi"){ #proceed with your code} 但是如何识别目录存在与否? 解决方法 使用-d( full list of file tests) if (-d "cgi-bin") { # directory called cgi-bin exists}elsif (-e "cgi-bin
要在使用文件之前查看文件是否存在,我们可以使用:
if (-e "filename.cgi") { #proceed with your code } 但是如何识别目录存在与否? 解决方法
使用-d(
full list of file tests)
if (-d "cgi-bin") { # directory called cgi-bin exists } elsif (-e "cgi-bin") { # cgi-bin exists but is not a directory } else { # nothing called cgi-bin exists } 注意,-e不区分文件和目录。要检查是否存在某个是纯文件,请使用-f。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |