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