Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: warning! -- Why?

by haj (Vicar)
on May 12, 2022 at 07:05 UTC ( [id://11143811]=note: print w/replies, xml ) Need Help??


in reply to warning! -- Why?

The and is the conditional here. The equal sign = has a higher precendence than and and Perl guesses (it's a warning, not a syntax error) that you meant to have a comparison on its left side. The expression might also not do what you want since the result of and is not its second operand, but I guess you want "\${$1}" as replacement string.

The cleanest (IMO) way to get rid of that warning is to use do, as you did, but to replace the and in the do block with a semicolon:

do { $used_options{ $1 } = 1; "\${$1}" }

Replies are listed 'Best First'.
Re^2: warning! -- Why?
by jwkrahn (Abbot) on May 12, 2022 at 16:27 UTC

    Bingo!

    Yes, I figured this out a couple of hours after I posted.

    Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11143811]
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-20 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found