in reply to Can't seem to see the problem here...
run the file test operators on what you think is a valid typed-in path:
-d $dir -f $dir -e $dir # or just call stat() [download]
you may have to chomp() the input to get rid of the CRLF at the end.