in reply to Traversing directories recursively

Try this:
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
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.

Replies are listed 'Best First'.
Re^2: Traversing directories recursively
by codeacrobat (Chaplain) on Nov 21, 2007 at 19:30 UTC
    Nice for a programming exercise. But one should should not reinvent the wheel. I'd use something that =~ m/File::Find(?:::Rule)?$/ :-)

    print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});