Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: How do I recursively process files through directories

by danderson (Beadle)
on Jun 17, 2004 at 23:57 UTC ( #367802=note: print w/ replies, xml ) Need Help??


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):

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!


Comment on Re: How do I recursively process files through directories
Download Code
Re^2: How do I recursively process files through directories
by porqui (Novice) on Sep 01, 2004 at 21:59 UTC
    Its way past June 11 2004, where is paco? I really miss h[im|er]. We could have been such famous friends.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367802]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2014-08-21 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (143 votes), past polls