opendir DIR, $directory; for my $dir (readdir DIR) { if (-d $dir) { print "Found directory: ", $dir, "\n"; push @directories, $dir; } } closedir DIR;