in reply to Re^3: Side effect of using undefined variable in regex
in thread Side effect of using undefined variable in regex

... the "last successfully matched regular expression" means the "last successfully matched regular expression in this scope" ... I think it might be worth a documentation patch...

I've been looking for an explicit discussion of this. Best I can come up with, and it's very indirect, is in Variables related to regular expressions:

The dynamic nature of the regular expression variables means that their value is limited to the block that they are in ...
I'm sure I've seen something better, more to the point. Not much time to look ATM.


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^5: Side effect of using undefined variable in regex
by haukex (Archbishop) on Jul 01, 2019 at 17:36 UTC
    I've been looking for an explicit discussion of this.

    Me too... I also found a few similar mentions in perlre:

    Capture group contents are dynamically scoped and available to you outside the pattern until the end of the enclosing block or until the next successful match, whichever comes first. ... These special variables, like the %+ hash and the numbered match variables ($1, $2, $3, etc.) are dynamically scoped until the end of the enclosing block or until the next successful match, whichever comes first.

    But I think the language regarding // is pretty direct, if IMHO misleading: "the last successfully matched regular expression is used". No mention of scope anywhere even near that statement...