use strict; my $path = "/usr/local/"; opendir( DIR, $path ) or die "could not open dir : $!\n"; my @files = readdir( DIR ); foreach my $file (@files) { print "$file\n" if( -d "$path/$file" ); }