Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: To return and/or not?

by BrowserUk (Patriarch)
on Oct 07, 2011 at 23:57 UTC ( [id://930267]=note: print w/replies, xml ) Need Help??


in reply to To return and/or not?

With this

return $a and not $b

The return happens first, and regardless of the value of $a. The rest of the line is therefore never even considered.

With this: $a and not $b the and is evaluated first, then the not $b if $a is false; then whatever is the result of that is returned by virtue of 'falling off the end' of the subroutine.

You might use return $a && !$b instead.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-25 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found