Sure, just write parens in their precedence-adjusting role
...and their list context inducing role.
Arjen
Update: edan is right. I was thinking about the m// operator which does return the matched subexpressions in list context.
| [reply] [d/l] |
I had to think about it for a minute, and reread parts of the perlop manpage, but Zaxo is right, and you're wrong. Sorry.
The s/// operator always returns the number of substitutions made, regardless of context. The parentheses here are indeed adjusting the precedence, because normally the =~ operator binds more tightly than assignment operators, = in this case. That's why without parens you first do the substitution, then assign the result to the variable. Putting the parens around the assignment forces that to happen first. In comes the handy lvalue property of assignment, so modifying the assignment with =~ has the effect of modifying the left-hand argument of the assignment. In the words of perlop:
Modifying an assignment is equivalent to
doing the assignment and then modifying the variable that
was assigned to.
| [reply] |