Please don't cross post, if your question is CGI based then use that list, otherwise use the other...

B. Fongo wrote:
I want to use mkdir(blah blah, o777), but want to first find out whether the directory "blah blah" exists.
I'm not if the -e option will bw right here. Let's say:


       unless (-e blah_blah) mkdir(blah_blah, 0777);
# Is this okay?



In general -e checks for file existence, -d checks to see if an existing file is a directory (or complains that the file doesn't exist).


perldoc -f -e

So your above code leaves a condition, where blah_blah exists but is *not* a directory which is likely to cause you problems. But since you haven't told us what happens in this failure case it is hard for us to say, but,

if (-e blah_blah) {
    unless (-d blah_blah) {
        die "File exists but is not directory";
    }
}
else {
    # don't forget to check mkdir's failure
    mkdir(blah_blah, 0777) or die "Can't make directory: $!";
}

HTH,

http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to