http://qs321.pair.com?node_id=11143811


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