in reply to How to list all the subdirectories in a directory
Lightly modified from readdir:
opendir(my $dh, $some_dir) or die "can't opendir $some_dir: $!"; my @subdir = grep { /^[^.]/ && -d "$some_dir/$_" } readdir($dh); closedir $dh;
Update:As JavaFan points out below, note the above code excludes any directory starting with a '.'. Seems reasonable to me since those are 'invisible' under most operations and your intent/spec is not explicit, but removing the regular expression from the grep test will remove the condition.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to list all the subdirectories in a directory
by JavaFan (Canon) on Aug 19, 2009 at 17:30 UTC |