采用递归的方法遍历目录:
my($root) = "C:\\temp";
DoDir($root);
 
sub DoDir {
  my($dir) = shift;
  my($file);
    opendir(DIR, $dir) || die "Unable to open $dir :$!";
    my(@files) = grep {!/^\.\.?$/ } readdir(DIR);
  closedir(DIR);
  foreach (@files) {
          if (-d ($file = "$dir\\$_")) {
                print "Found a directory: $file\n";
             DoDir($file); 
          } else {
              print "File $file\n";
     }
  }
}

相关文章:

  • 2022-12-23
  • 2021-11-12
  • 2021-11-01
  • 2021-08-02
  • 2021-08-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-28
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案