遍历当前目录

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

my $path = `pwd`;
chomp $path;     # `pwd`命令结尾有个回车符,需要chomp去掉
print "$path\n ";
opendir DIR ,$path || die "cant open $!";
foreach my $file (readdir DIR) {    # readdir 将读出所有的文件和目录,包括.和..
    print "$file\n ";
    }