user391986 user391986 - 1 year ago 57
Perl Question

perl iterate through directories

I'm trying to get the name of all directories in the specified path

I tried the following but that gives me every level down not just at the path i specified

find(\&dir_names, "C:\\mydata\\");
sub dir_names {
print "$File::Find::dir\n" if(-f $File::Find::dir,'/');

Answer Source
my @dirs = grep { -d } glob 'C:\mydata\*';