in reply to How to list all the subdirectories in a directory

You can accomplish this by determining the contents of the directory (opendir, readdir, closedir) combined with the -d file test (-X). If you run into difficulties, post some code and we'll help you debug.

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
    I'm curious why you exclude all directories starting with a dot. Sure, that excludes '.' and '..' (a case could be made to exclude them), but it also excludes directories like .git.