in reply to Re^7: Using pos() inside regexp (no /e)
in thread Using pos() inside regexp
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Using pos() inside regexp (no /e)
by andal (Hermit) on Oct 14, 2010 at 10:03 UTC | |
by ikegami (Patriarch) on Oct 14, 2010 at 16:24 UTC | |
by andal (Hermit) on Oct 15, 2010 at 07:35 UTC | |
by Anonymous Monk on Oct 15, 2010 at 08:11 UTC | |
by andal (Hermit) on Oct 18, 2010 at 11:30 UTC | |
|