pen has asked for the wisdom of the Perl Monks concerning the following question:
I am new at perl and am trying to get a handle on how the basics work.
All I am trying to do is search a directory in windows and return wether the items in it are files or directories.
What I have so far is this...
if I have the prompt at C: and I run the lines of code below only a couple of the directories are found. If I then change to D: in the prompt and run it again I get what I expect. For what reason does it do this. I have seen code that works but for my own understanding I would like to know what is going wrong here.
Thanksopendir dirs2, "D:/" or die "Could not open directory: $!"; while ($_ = (readdir dirs2)) { if (-d $_) { print "Directory: $_\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching directories
by LazerRed (Pilgrim) on Sep 23, 2003 at 01:48 UTC | |
by pen (Acolyte) on Sep 23, 2003 at 13:32 UTC | |
by bart (Canon) on Sep 23, 2003 at 13:52 UTC | |
|
Re: Searching directories
by Roger (Parson) on Sep 23, 2003 at 05:53 UTC | |
by softworkz (Monk) on Sep 23, 2003 at 16:08 UTC | |
by Roger (Parson) on Sep 23, 2003 at 22:50 UTC | |
|
Re: Searching directories
by PriNet (Monk) on Sep 23, 2003 at 03:32 UTC |