Thanks for this, it's clear and explains why the (?{...}) solution didn't (and could never) work.
I've not used \G and /c before. From reading perlre I now understand that \G essentially 'anchors' that point to index pos() into the string. I'm a little confused by the description for the /c modifier. From perlre v5.24:
c - keep the current position during repeated matching
and from the referenced perlretut
A failed match or changing the target string resets the position. If you don't want the position reset after failure to match, add the "//c", as in "/regexp/gc".
I assume then, should the data I'm parsing with the regex be well formatted, then pos() will never be reset and so the /c modifier is not needed? But were any matches fail, things would break
Is this a correct understanding of \G and /c?
In reply to Re^2: Modifying pos() from within (?{...})
by mxb
in thread Modifying pos() from within (?{...})
by mxb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |