opendir(IMD, $dirtoget) || die("Cannot open directory"); @thefiles = readdir(IMD); closedir(IMD); foreach $f (@thefiles) { if (-d $f) { print "$f
\n"; } }