Perl:if语句或者忽略if语句

时间:2015-09-11 17:37:11

标签: perl if-statement

这是我的代码行:

#!/usr loca/bin/perl                                                           
use warnings;                                                                   
use strict;  
...
...
if ($file ne "." || $file ne "..")

我也尝试过:

if ($file ne "." or $file ne "..")

if语句总是通过,因为它无法识别我设置的条件。我一次做了一个,他们按预期工作。任何人都可以帮助确定我需要如何正确设置它?谢谢!

1 个答案:

答案 0 :(得分:4)

Everything 不是单个点,也不是双点!

你的意思是

if ( $file ne "." and $file ne ".." ) { ... }

你应该看glob而不是opendir / readdir