perlfile-find

perl list path of subdirectory using File::Find


How can I get all the paths of a subdirectory foo into an array in perl using File::Find

 abc\def\sdfg\gthrth\foo\
 abc\def\fgfdg\foo\
 abc\def\sdfgdsg\fgdfg\gfdgf\tytty\foo\
 abc\def\foo\

I want to get the full paths of all subdirectories foo inside directory abc\def into an array


Solution

  • use File::Find::Rule qw( );
    
    my @paths = File::Find::Rule->name('foo')->in(@dirs);