in reply to Problems with -filetest on readdir results

You need to provide -d with the $path ...

#!/usr/bin/perl -w use strict; my $path = "/usr/bin"; opendir DIR, $path or die "Couldn't read directory: $!"; my @directories = grep { -d "$path/$_" } readdir DIR; closedir DIR; foreach (@directories) { print $_, "\n"; }

Update: Changed $path to "$path/$_" so it prints out only the directories (as opposed to all the files). Thanks to ChemBoy for spotting this and providing the fix.