opendir DIR, "." or die "$!"; foreach my $dir (grep { -d $_ } readdir DIR) { # Do something with $dir } closedir DIR;