Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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.


Replies are listed 'Best First'.
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    |    205065726c204861636b6572
    I wear my Geek Code on my finger.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://21676]
[ambrus]: hallo, cbstream still working?

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-05-24 22:17 GMT
Find Nodes?
    Voting Booth?