Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: If File Exists

by cds (Sexton)
on Jun 19, 2000 at 14:10 UTC ( [id://18782]=note: print w/replies, xml ) Need Help??


in reply to If File Exists

You may also want to check that it's a file (not a directory or special file), and that it's readable and writeable. Try:

if (-e "$ENV{REMOTE_ADDR}.$ENV{HTTP_COOKIE}.txt") { if (-f _) { if (-r _) { if (-w _) { #Do stuff here } else { #Not writable } } else { #Not readable } } else { #Not a file } } else { #Doesn't exist }

You can put all the checks in the one if by anding them if you only need to check that the file exists and is accessable.

Colin Scott
If you build it, they will be dumb...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found