-------------------------------
use strict;
use warnings;
my @tree=<*>;
foreach (@tree){
&if_a_tree($_);
}
sub if_a_tree{
if(-d){
print "$_ is a directory\n";
chdir $_;
my @tree=<*>;
foreach(@tree){
&if_a_tree($_);
}
chdir "..";
}
if(-f){
print "$_ just a file\n";
}
}
-----------------------------------------
use Cwd;
use File::Find;
find(\&printFilename, getcwd);
sub printFilename {
print "Dir name: ", $File::Find::dir, "\n";
print "File name: ", $_, "\n";
print "Full name: ", $File::Find::name, "\n";
print "\n";
}
-----------------------------------------
阅读(1311) | 评论(1) | 转发(0) |