The files you get from readdir are relative to your directory $path and -d test for files from the current directory.
So, you need to specify your path in the test :
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" );
}