user391986 user391986 - 6 months ago 9
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,'/');
}

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