in reply to How do I recursively process files through directories
Found this somewhere else, and it works wonderfully for me, so I thought I'd pass it on (yes, it's recursive, but it's also easier to read/write/maintain than the iterative sol'n above):
Go paco!
sub recurse { my($path) = @_; print( "working in: $path\n" ); # append a trailing / if it's not there $path .= '/' if($path !~ /\/$/); # loop through the files contained in the directory for my $eachFile (glob($path . '*')) { # if the file is a directory if( -d $eachFile) { # pass the directory to the routine ( recursion ) recurse($eachFile); } else { handleFile( $eachFile ); } } }
Go paco!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How do I recursively process files through directories
by porqui (Acolyte) on Sep 01, 2004 at 21:59 UTC |
In Section
Seekers of Perl Wisdom