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

Re: CGI Directory Lister

by snowcrash (Friar)
on Jul 25, 2001 at 09:36 UTC ( [id://99574]=note: print w/replies, xml ) Need Help??


in reply to CGI Directory Lister

hi!

your main problem seems to be that the code in the while loop doesn't get executed:
($file == "." || "..") is not the same as ($file eq "." || $file eq ".."), as the string constant </code>".."</code> evaluates true all the time and the whole expression is true.
you have to use eq if you compare strings, == is the operator to compare numerical values! always use the -w option in the shebang line (/path/to/perl -w) or use warnings; to to enable warnings, to notice nasty litte bugs!

Change that line in your code to something like this:
while (defined($file = readdir(PARSEDIR))) { next if ($file eq "." || $file eq ".." || !-r $dir); ### [*snip*] }
hope to help,
snowcrash //////

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-04-25 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found