How can I recursively read out directories in Perl?

前端 未结 6 2410
一生所求
一生所求 2021-02-14 06:08

I want to read out a directory recursively to print the data-structure in an HTML-Page with Template::Toolkit. But I\'m hanging in how to save the Paths and Files in a form that

6条回答
  •  渐次进展
    2021-02-14 06:45

    This should do the trick

     use strict;
     use warnings;
     use File::Find qw(finddepth);
     my @files;
     finddepth(sub {
          return if($_ eq '.' || $_ eq '..');
          push @files, $File::Find::name;
     }, '/my/dir/to/search');
    

提交回复
热议问题