Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: warning! -- Why?

by kcott (Archbishop)
on May 12, 2022 at 09:37 UTC ( [id://11143821]=note: print w/replies, xml ) Need Help??


in reply to warning! -- Why?

G'day jwkrahn,

It's a common mistake to forget, or not realise, that "&&" has a higher precedence than "=" which, in turn, has a higher precedence than "and". See "perlop: Operator Precedence and Associativity" (there's a table at the end of that section which lists the order of precedence).

Changing "and" to "&&" gets rid of the warning; however, in this instance, that's probably not what you want. Compare these two:

$ perl -MO=Deparse,-p -e '($used_options{ $1 } = 1 and "\${$1}")' (($used_options{$1} = 1) and ("\${$1}")); $ perl -MO=Deparse,-p -e '($used_options{ $1 } = 1 && "\${$1}")' ($used_options{$1} = "\${$1}");

— Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-20 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found