Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: open failure code

by tachyon (Chancellor)
on Nov 26, 2003 at 23:17 UTC ( #310408=note: print w/replies, xml ) Need Help??


in reply to open failure code

Precedence and operator binding is the issue. But...why not just.....

if (open FH, $log) { ....send tail of log file... } else { ....send "server is down. Perl say $!" }

Note the error code (string reason) is set in $! if open, print, close, mkdir, unlink.....fail. Internal Perl functions return 1 if they succeed, 0 or undef if they fail. If you want to do the  || $scalar = 'blah' you can do this:

blah() || do{ $scalar = 'blah'; more_stuff() }

cheers

tachyon

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2021-03-07 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (121 votes). Check out past polls.

    Notices?