Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

another directory question

by jrsmith (Pilgrim)
on Apr 28, 2000 at 17:14 UTC ( #9576=perlquestion: print w/ replies, xml ) Need Help??
jrsmith has asked for the wisdom of the Perl Monks concerning the following question:

i have another problem.. i am using -d to test whether it is a directory or not but it is telling me that all my directories are not directories. the only directories it will recognize as directories are NOT directories, and these are the . and .. used to navigate to previous dirs in win32. this is what i get when i run the script:
. is a directory. .. is a directory. Cannot determine filetype of digsol.
here is the filetest section of my script:
if (-f $i) {   print OUTPUT "$i is a file.\n"; } elsif (-d $i) {   print OUTPUT "$i is a directory.\n"; } else {   print OUTPUT "Cannot determine what $i is.\n"; }
are there any known problems with -d and win32? i have looked around here and other sites and haven't seen any similar problems, maybe i'm just doing something wrong? TIA for any insight you can provide
JR

Comment on another directory question
Re: another directory question
by jrsmith (Pilgrim) on Apr 28, 2000 at 17:39 UTC
    nevermind i found out what is wrong... -d was testing just the directory name specified by $i when i should have included the path in that like e:/$i or $path$i. thanx anyway :)
      Depeding on how long you intend to spend doing stuff in each directory, it might be a good idea to do a chdir into that directory. This would avoid running into problems like the one you just had.

      This is one of those philosofical issues, like what's best:
      • relative links
      • absolute urls
      Each person has a particular way of doing things, but I just tend to think its a matter of what makes things clearer. In your case, it could be:
      if (-f "$path/$leaf") { } # or simply chdir($path) || warn(); if (-d $leaf) { }
      cheers!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://9576]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-08-29 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (278 votes), past polls