Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Checking for valid directory

by cbro (Pilgrim)
on Jul 03, 2003 at 15:24 UTC ( #271198=note: print w/ replies, xml ) Need Help??

in reply to Checking for valid directory

I'm not sure why you have the single backslash in your directory name, but if you are using Windows then you need to escape the slash, (e.g. my $dir = "\\TestDir";).

Either way, don't use backslashes. This way you don't have to worry about escaping them. Here's an example (I'm assuming your using windows because of your $dir definition):

my $dir = "c:/docume~1/chris/TestDir"; if (-d $dir) { print "It Exists"; } else { print "Does Not Exist"; }

So, the first method you tried...the one w/out $dir in quotes should have worked. Try making $dir an absolute path, and use forward slashes. See if that makes a difference.

Comment on Re: Checking for valid directory
Select or Download Code
Replies are listed 'Best First'.
Re: Re: Checking for valid directory
by Anonymous Monk on Jul 03, 2003 at 15:44 UTC
    Sorry folks, I had the output going to stderr so that is why I didnt see the output. Again, sorry to not catch this before I posted!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://271198]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2015-10-13 19:41 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (314 votes), past polls