in reply to Read directories' contents, add subdirs back into directory list
More importantly, how deep are you trying to go? Even if you use another collection, the names you get from readdir are relative to their parent. So a readdir on them isn't going to yield any more subdirs. If you really want to recurse, you're going to have to do something different.
Perhaps File::Find would do the trick for you:
use strict; use File::Find; my @dirs = ( '/home/ned', '/usr/games' ); sub doStuff { print shift() . "\n"; } find( sub { doStuff($File::Find::name) unless -d _ }, @dirs );
|
|---|