in reply to Traversing directories recursively
It seems shorter (if you ignore/eliminate the makeup I added to enhance readability) and much simpler than what you have and works. Hope this helps.sub browse($) { my $path = $_[0]; #append a / if missing if($path !~ /\/$/) { $path .= '/'; } #loop through the files contained in the directory for my $eachFile (glob($path.'*')) { #if the file is a directory if(-d $eachFile) { #browse directory recursively browse($eachFile); } else { your file processing here } } }#browse
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Traversing directories recursively
by codeacrobat (Chaplain) on Nov 21, 2007 at 19:30 UTC |