解决方法
您需要将opendir,readdir和closedir函数与-f file test运算符结合使用:
opendir(my $dh,$some_dir) || die $!; while(my $f = readdir $dh) { next unless (-f "$some_dir/$f"); print "$some_dir/$f\n"; } closedir $dh;