Using "pos() = $new_pos" does not work during the matching process.
That is also wrong. pos works in a substitution expression just like it does outside a substitution expression. Had you checked, you would have seen that lvalue pos does in fact change the var's pos when used in the substitution expression.
$ perl -E'my $x="abc"; $x=~s/./say pos($x); pos($x)=2; say pos($x)/e;' 0 2
s/// simply doesn't care that you changed it. Like I've already explained, it simply doesn't make any sense for s/// to check if the string's pos has changed. Why are you still asking about this?
In reply to Re^8: Using pos() inside regexp (no /e)
by ikegami
in thread Using pos() inside regexp
by braveghost
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |