in reply to Re^3: Regular Expressions
in thread Regular Expressions

I don't think it's documented. It's just a case of having one place to store a capture and capturing into it multiple times. Each time a capture happens, the old value is overwritten. I wish it were documented, though.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^5: Regular Expressions
by Anonymous Monk on May 18, 2005 at 06:01 UTC
    It is documented. perldoc perlre
        The numbered match variables ($1, $2, $3, etc.) and the related
        punctuation set ($+, $&, $`, $', and $^N) are all dynamically scoped
        until the end of the enclosing block or until the next successful match,
        whichever comes first. (See "Compound Statements" in perlsyn.)
      I read "the next successful match" as a separate Perl operation, not the internal iteration involved in matching ()*. There is, technically, nothing that dictates the order of internal matching, and if the overall match fails, $1 is not set to the last iteration of ()* that did match.

      Caution: Contents may have been coded under pressure.