Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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]
[mark4]: ...And some of my confusion is that "PAR-Packer" is not available in the default repository for the 64 bit active-state perl

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2018-01-19 21:39 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (223 votes). Check out past polls.