- 论坛徽章:
- 0
|
#!/usr/bin/perl -w
use strict;
our $WORK_DIR = $ARGV[0] . '/test';
our @a;
our $tmp;
&ReadDir($WORK_DIR);
# foreach $tmp (@a)
# {
# print "2222222","\n";
# print $tmp,"\n";
# }
sub ReadDir
{
my ($dir) = @_;
opendir(DIR, $dir);
print $dir,"\n";
foreach my $element (@a=readdir(DIR))
{
my $full_path = "$dir/$element";
if ('.' eq $element || '..' eq $element) { next; }
print $full_path,"\n";
print "1111111","\n";
if (-d $full_path)
{
print "directory","\n";
&ReadDir($full_path);
}
else
{
print "not directory","\n";
last;
}
}
closedir(DIR);
}
递归遍历子目录
现在的问题是 根目录下有多个子目录 它就只能遍历一个。。 |
|