Dear Monks,
perlre says this:
(??{ code })
This is a "postponed" regular subexpression. The code is evaluated at run time, at the moment this subexpression may match. **The result of evaluation is considered a regular expression and matched as if it were inserted instead of this construct.**
Then perlre says:
Note that this means that the contents of capture groups defined inside an eval'ed pattern are not available outside of the pattern...
...Thus,
('a' x 100)=~/(??{'(.)' x 100})/
will match, it will not set $1.
Huh? I checked, and in fact $1 is not set. So in my opinion, the last quoted line should say:
Despite the regex insertion, *confoundingly* the capture groups inside this construct are not available after the insertion.
In other words, I don't see how by inserting the resulting regex instead of this construct it follows that the capture groups in the regex won't be available, which perlre seems to think is self-evident.
In reply to Evaluating code in a regex at runtime: (??{...}) by 7stud
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |