This is one reason why I prefer glob to opendir:
my @dirs= grep { -d } glob( "$dir/*" );
works. It forces you to either chdir or prepend the directory name (and often makes much simpler code).
You also forgot to filter out "." and ".." in your version. Of course, my version won't report ".cpan" (which might be a bug or a feature, depending), and I wish glob provided an option to make that trivial to do.
- tye
In reply to Re^2: Why does File::Find chdir? (glob++)
by tye
in thread Why does File::Find chdir?
by jplindstrom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |