Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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!

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
    Its way past June 11 2004, where is paco? I really miss h[im|er]. We could have been such famous friends.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367802]
[Discipulus]: indeed! new firefox seems poorer: many tab crash, and you open this link in FF?
[Discipulus]: problem scrolling even main page..;=(
[LanX]: holli -> Good Intentions: Wikisyntax for the Monastery
[LanX]: monklinks are automatically converted ...
[LanX]: On another node, I just saw yesterday that the everything engine supports auto-paragraph whithout the need to type <p>
LanX i.e. the newest everything engine

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-11-20 19:09 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.