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

RE: RE: Re: or or

by ahunter (Monk)
on Jul 09, 2000 at 01:57 UTC ( #21676=note: print w/ replies, xml ) Need Help??


in reply to RE: Re: or or
in thread or or

I'm not sure what you mean here - you provide a classic example of where or is most certainly not appropriate (as if you use it, $param will never get the value of $default).

That is,

$param = $value or $default;
Will result in $param always getting the value of $value, never $default. or has lower precedence than = (in fact it has the absolute lowest precedence of all the operators). Maybe it was just me not being clear, though. You should always use 'or' where what you really want to say is:
($param=$value) or die "darn"
That is, you don't want the value of die to get assigned to $param (yeah, die doesn't return very often. But it forces scalar context, which is why the alternative is a Bad Thing). Using or, your example would have to be:
$param=$value or $param=$default
So it's not always a matter of style.

Andrew.


Comment on RE: RE: Re: or or
Select or Download Code
RE: RE: RE: Re: or or
by Aighearach on Jul 09, 2000 at 08:49 UTC
    I don't think you understood my point. My point was, TMTOWTDI, so depending on which stucures you build your program with, one or the other will be more commonly useful.

    Sorry to have been so unclear.

    But I'm not sure what your point is about the code, yes I gave an example that is not appropriate with or, it illustrates that your algorithm logic is the determining factor in which operator is more common.

     

    Paris Sinclair    |    4a75737420416e6f74686572
    pariss@efn.org    |    205065726c204861636b6572
    I wear my Geek Code on my finger.
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2014-10-20 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (92 votes), past polls