Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: open failure code

by tachyon (Chancellor)
on Nov 26, 2003 at 23:17 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://310408]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found