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

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.)

Replies are listed 'Best First'.
Re^6: Regular Expressions
by Roy Johnson (Monsignor) on May 18, 2005 at 11:06 UTC
    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.