Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^2: Looking for discussions of "block after or" syntax error

by davido (Archbishop)
on May 01, 2013 at 21:04 UTC ( #1031646=note: print w/replies, xml ) Need Help??

in reply to Re: Looking for discussions of "block after or" syntax error
in thread Looking for discussions of "block after or" syntax error

print returns false on failure, in which case the 'and' would short-circuit and exit would never get called.

Granted, it's pretty unusual for print to fail -- so rare that we rarely test for success in our prints, and usually don't think in terms of "this could fail", but when you absolutely positively want to exit, don't include a logical test on print's success.


Replies are listed 'Best First'.
Re^3: Looking for discussions of "block after or" syntax error
by Laurent_R (Abbot) on May 01, 2013 at 21:34 UTC

    Agreed. I did not think about that. And I usually don't do such a print anyway but rather a die statement (although, going to the end of this logic, what do you do if die fails? Do you 'die "i failed" or die "die failed"'?

    Usually, the only reason I want to know that opening a file failed if to get an immediate diagnostic of the reason for the program failure. If the print statement fails, well, I am likely to have more severe problems than just file opening.

      die doesn't have a useful return value (to my knowledge), and would never be placed on the lefthand side of a logical short circuit.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2016-10-22 00:27 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.