perl 遍历目录并且对目录中的文件进行操作

opendir (DIR, $dir) or die "can't open the directory!";
my @dir = readdir DIR;
foreach my $file (@dir) {


}

对二级目录进行遍历,操作二级目录里的文件

my $rawpath=$ARGV[0];

opendir (DIR,$rawpath) or die "can't open!";
my @file = readdir DIR;
foreach my $file (@file){
    my $newdir = $rawpath."/".$file;
    opendir(DIR2,$newdir) or die "can't open $newdir!";
    my @file2 = readdir DIR2;
    foreach my $file2 (@file2){
    
    
    }
}

 

posted @ 2018-09-27 14:11  maxsmile17  阅读(2054)  评论(0编辑  收藏  举报