Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: if (open(FH, $path)) { ?

by bkiahg (Pilgrim)
on May 03, 2004 at 14:25 UTC ( [id://350020]=note: print w/replies, xml ) Need Help??


in reply to Re: if (open(FH, $path)) { ?
in thread if (open(FH, $path)) { ?

Thanks Ryszard this is a better way!

Replies are listed 'Best First'.
Re: Re: Re: if (open(FH, $path)) { ?
by ysth (Canon) on May 03, 2004 at 16:37 UTC
    Not really; many platforms allow additional settings to provide/forbid access not taken into account by -r, so the easiest way is actually to try the open. The problem with that is that some other error may crop up and you'll never find out about it because you are ignoring all errors; you may want to ignore only permissions errors and carp on any others:
    use Errno; if (open $fh, "<", "foo/bar/baz") { ... } elsif ($!{EPERM}) { print "no go!\n"; } else { print "error opening foo/bar/baz: $!"; }
    Of course, to be really uptight about complaining about unexpected errors but ignoring lack of read permission to the file, you should go on to make sure the EPERM didn't result from lack of access to one of the directories traversed, but I'm not going there...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 08:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found