I used the following where $loc held a directory( depending on where you
are in the code, you may need the name to be fully qualified):

        if  ( ! -e $loc) {
          mkdir("${loc}",0666)   || die "${prog}Unable to create directory
${loc}";
       }
Wags ;)
-----Original Message-----
From: David Simcik [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 16, 2001 12:21
To: Perl Beginners
Subject: Checking for Directory Existence


Hey folks,
        This would seem to be a trivial thing, but I can't find a great
answer
anywhere for it. I want to do a mkdir, but before I do, I want to confirm
that the dir I'm about to make doesn't already exist.

Would the -X operators (particularily -e) work with DIRHANDLES??? That would
certainly make my life easier. Otherwise, the only other option I can think
of is to do a Opendir() before the Mkdir and test to ensure that the Opendir
fails. That's a bit kludgey in my mind, so can anyone shed some light on the
situation?

THanks!
DTS


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

Reply via email to