需要遍历目录对特定目录做指定操作:
#!/usr/bin/perl -w
use strict;
use warnings;
sub readSubDir($){
my $DIR_PATH=shift;
opendir DIR, $DIR_PATH or die "Can not open \"$DIR_PATH\"\n";
my @filelist = grep { $_ ne '.' and $_ ne '..' } readdir DIR;
chdir($DIR_PATH);
my @subDir;
foreach my $file (@filelist) {
if(-d $file){
if($file eq "RCS"){
print $DIR_PATH."/".$file."\n";
#system("co RCS/*");
} else {
#print $DIR_PATH."/".$file."\n";
push @subDir, $file;
}
}
}
foreach my $dir(@subDir){
&readSubDir($DIR_PATH."/".$dir);
}
}
my $ROOT_DIR_PATH="/home/";
readSubDir($ROOT_DIR_PATH);
exit(0);
阅读(807) | 评论(0) | 转发(0) |