> -----Original Message-----
> From: K.L. Hayes [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 12:28 AM
> To: [EMAIL PROTECTED]
> Subject: Should I use -e -d or opendir ?
> 
> 
> Hello All,
> 
> I've found lot's of info on how to check if a file exists but nothing
> about checking if a directory exists. I've posted the relevant code
> below along with 3 variations of how I "think" it might work. If
> somebody could point to the one that is "correct" or knows of a better
> way I'd appreciate the help. Thank you.
> 
> <CODE_SNIP>
> use constant USER_PATH => '/home/~client/htdocs/clients/';
> $path = USER_PATH . $personal_key;
> 
> ## Is This Correct? ##
> if (-e "$path") {
>         &get_on_with_it }
>         else { &errorMsg }
> 
> ## Or This? ##
> opendir(CLIENT, "$path") or die " &errorMsg ";
> closedir(CLIENT);
> &get_on_with_it
> 
> ## Or Is It This? ##
> if (-d $path) {
>         &get_on_with_it }
>         else { &errorMsg }
> <!CODE_SNIP>

Probably you just want -d.

-e returns true for plain files, symlinks, sockets, etc. as well as
for directories, so that's not what you want.

opendir() will fail if you don't have read permission on the directory.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to