Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: To || or not to or and why.

by shenme (Priest)
on Sep 15, 2003 at 22:56 UTC ( [id://291676]=note: print w/replies, xml ) Need Help??


in reply to To || or not to or and why.

Looking through perlop I found an example showing one nastiness:
@info = stat($file) || die; # oops, scalar sense of stat! @info = stat($file) or die; # better, now @info gets its due
I guess an equivalent to your situation might be:
my @Candidates = @_ or return; my @Candidates = @_ || return;
The second will return undef or set the only element of @Candidates to the number of arguments passed in.   So in effect 'or' is allowing operators, including assignments, to be completely evaluated, without inducing any side-effects.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-19 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found