perl获取文件夹下所有文件名的代码,供大家学习参考。
#!/Perl/bin/perl -w
$dir_name='C:perl-test';
opendir(DIR, "$dir_name") || die "Cannot open $dir_name";
@a=readdir DIR;
foreach (@a) {
next if ($_=~/^./);
print "$_n";
}
closedir DIR;
#!/Perl/bin/perl -w
#$dir_name='C:perl-test';
$dir_name="C:perl-test";
opendir(DIR, "$dir_name") || die "Cannot open $dir_name";
while ($name=readdir DIR) {
next if $name=~/^./;
print "$namen";
}
closedir DIR;