note
tobyink
<blockquote><p><i>"It ought to be easy to recognize an unquoted $1 as a function argument and issue a warning"</i></p></blockquote>
<p>The problem occurs in:</p>
<c>
return $1 + sub_that_does_regex_capturing(...);
</c>
<p><c>$1</c> is not a function argument in that. <c>$1</c> hasn't been a function argument in any of the examples in this thread.</p>
<p>The problem is writing an expression where one of the operands has a side-effect that can alter the value of another operand. This is very hard to detect through static analysis of source code; it's probably not especially easy to detect at run-time either. Heuristics may be able to catch some common cases.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-757127">
<small><small>
<tt>perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
</tt></small></small>
</div></div>
1008823
1008844