in reply to list of files in subdirectories

use File::Find::Rule, see example at Re^2: read the whole folder files (don't specify maxdepth)

Replies are listed 'Best First'.
Re^2: list of files in subdirectories
by Anonymous Monk on Jun 06, 2012 at 14:56 UTC

    Here is a nice example from the book Higher-Order Perl by Mark Jason Dominus

    This example is for win32, but it is easily changable:

    use strict; use warnings; use Time::HiRes qw(gettimeofday tv_interval); my $start_time = [gettimeofday]; my $inp_dir = 'c:\temp\Tmp_User'; my ( $startdir ) = @ARGV; $startdir = $inp_dir; ( defined $startdir ) || usage(); walk_path( \&is_req_file, $startdir ); my $elapsed = tv_interval($start_time); $elapsed = sprintf "%.04f", $elapsed; print "\n...Elapsed is $elapsed sec\n"; 1; sub is_req_file { my ($filn) = @_; print "$filn\n"; return 1; } sub walk_path { my ( $filefunc, $startdir ) = @_; my $dos_cmd = "dir $startdir /b /S /A:-D"; map { $filefunc->($_) } ( split /\n/, qx{$dos_cmd} ); return; }

    The advantage is, that it runs really fast on windows.

    The missing sub usage is left as an exercise.