跟我一起学 第2课
foreach my $name (@names){ next if ($name eq ".");next if ($name eq "..");
if (-d $name){ # is this a directory?
&ScanDirectory($name);#再次调用这个函数
next;
}
if ($name eq "core") { # is this a file named "core"?
# if -r specified on command line, actually delete the file
if (defined $r){
unlink($name) or die "Unable to delete $name:$!\n";
}
else {
print "found one in $workdir\n";
}
}
}
chdir($startdir) or die "Unable to change to dir $startdir:$!\n";
}
&ScanDirectory(".");
页:
[1]