要在使用文件之前查看文件是否存在,我们可以使用:
if (-e "filename.cgi") { #proceed with your code }
但是如何识别目录存在与否?
@H_404_6@解决方法
使用-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。
@H_404_6@ @H_404_6@