in reply to Read directories' contents, add subdirs back into directory list

In general, if you're using for() to iterate over a list that you're modifying within the loop: that's a danger sign. Something will get messed up sooner or later, and be tough to track down. Instead, try this simple structure instead of the for:
while(@dirs) { my $dir=shift @dirs; # Rest of loop here }
This way you can throw stuff anywhere you want to in @dirs, and it'll all get processed eventually. By changing the push to an unshift, you'll get a depth-first search instead of breadth-first. Nifty, eh?

You do have a couple of other small bugs, which other posters have pointed out.

  • Comment on Re: Read directories' contents, add subdirs back into directory list
  • Download Code