develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24202] Perl 5.8.0 regexp anomaly

From:
Ronald J Kimball
Date:
October 15, 2003 09:07
Subject:
Re: [perl #24202] Perl 5.8.0 regexp anomaly
Message ID:
20031015134319.GA32012@penkwe.pair.com
On Tue, Oct 14, 2003 at 09:38:11PM -0700, Mario Nigrovic wrote:

> >2) @+ is a special regex variable (since 5.6.1)
> 
> I suppose this explains why the pattern matched differently between the
> first and second applications, but I can't seem to find documentation
> about @+ anywhere

perldoc perlvar

       @+      This array holds the offsets of the ends of the
               last successful submatches in the currently active
               dynamic scope.  "$+[0]" is the offset into the
               string of the end of the entire match.  This is
               the same value as what the "pos" function returns
               when called on the variable that was matched
               against.  The nth element of this array holds the
               offset of the nth submatch, so "$+[1]" is the off-
               set past where $1 ends, "$+[2]" the offset past
               where $2 ends, and so on.  You can use "$#+" to
               determine how many subgroups were in the last suc-
               cessful match.  See the examples given for the
               "@-" variable.

HTH,
Ronald



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About