On 1/16/01 22:49, Scott R. Godin at [EMAIL PROTECTED] wrote:

> fails:
> my $GameType = param('mapstyle') or $default_mapstyle;
> 
> works:
> my $GameType = param('mapstyle') || $default_mapstyle;

According to perlop:

    [ ... ]
    left        ||
    [ ... ]
    right       = += -= *= etc.
    [ ... ]
    left        or xor

In other words, || has a higher precedence than =, which has a higher
precedence than 'or'. So the statement that works parses as

    my $GameType = (param('mapstyle') || $default_mapstyle);

which is what you'd expect, but the failing one parses as

    (my $GameType = param('mapstyle')) or $default_mapstyle;

which is probably not what you wanted.

> Am I mistaken in assuming that "I should use 'or' because this is 'string
> values'" or does this happen "simply because the possibility of returning
> undef exists in the expression" ?

I think you are mistaken. Are you thinking "'or' for strings" because of
"'eq' for strings"? 'or' vs. || is simply a matter of operator precedence.

-- 
Craig S. Cottingham
[EMAIL PROTECTED]
PGP key available from:
<http://pgp.ai.mit.edu:11371/pks/lookup?op=get&search=0xA2FFBE41>
ID=0xA2FFBE41, fingerprint=6AA8 2E28 2404 8A95 B8FC 7EFC 136F 0CEF A2FF BE41


Reply via email to