为什么下面的代码不工作?为什么一个目录列表不工作我的Windows系统上?
-d
和-f
不是我的Windows机器上运行。
use strict;
use warnings;
use Data::Dump qw/pp/;
my $path="C:/perl/workspace";
opendir (DIR, $path) || die "Error in opening dir $path\n";
my (@file,@dir);
while (my $filename=readdir(DIR)) {
next if ($filename =~ m/^\./);
if (-f $filename) {
push(@file,$filename);
} elsif (-d $filename){
push(@dir,$filename);
}
}
#pp \@file,\@dir;
print "@dir";
关于 “else if” 语句:[?为什么Perl中有 'ELSIF' 而不是 'elseif的'](http://stackoverflow.com/questions/659553/how-does-elsif-work-in-perl ) –