or download this
my $dir = "directory"; # this dir exists
my $no_dir = "no.such.directory"; # this one does not
...
print "$dir is a directory" if ( -d $dir );
print "$no_dir exists" if ( -e $no_dir );
print "$no_dir is a directory" if ( -d $no_dir );