Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: "or die" versus "|| die"

by gellyfish (Monsignor)
on Jun 24, 2005 at 15:08 UTC ( #469732=note: print w/ replies, xml ) Need Help??


in reply to Re: "or die" versus "|| die"
in thread "or die" versus "|| die"

No they cannot be used interchangeably in all places, the word versions are specifically guaranteed to have lower precedence than the symbol versions (infact guaranteed to have the lowest precedence of any operators), you might care to try for instance:

open ONE, "somefilethatdoesnexist" or print "one: $!\n"; open TWO, "somefilethatdoesnexist" || print "two: $!\n";
As you can see the latter doesn't behave as expected as the '||' binds more tightly and ends up taking the value of the filename - infact the check is optimised away because this is essentially a no-op, as the output from B::Deparse shows:
print "one: $!\n" unless open ONE, 'somefilethatdoesnexist'; open TWO, 'somefilethatdoesnexist';

/J\


Comment on Re^2: "or die" versus "|| die"
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-05-25 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (478 votes), past polls