Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: "or die" versus "|| die"

by jeffa (Chancellor)
on Jun 24, 2005 at 14:56 UTC ( #469727=note: print w/ replies, xml ) Need Help??


in reply to "or die" versus "|| die"

In your example it doesn't matter. One binds more tightly than the other, is the only real difference -- well, that and readablilty. || binds tighter. So, if you want to die after an assignment use or:

my $foo = $bar->fetch('baz') or die "something went wrong\n";
And if you want a default value, use ||
my $foo = $bar->fetch('baz') || 'default';

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)


Comment on Re: "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://469727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2015-07-04 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (59 votes), past polls