Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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

Replies are listed 'Best First'.
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) { }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://9576]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2018-05-22 03:35 GMT
Find Nodes?
    Voting Booth?