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

Re: [perl #24202] Perl 5.8.0 regexp anomaly

Ronald J Kimball
October 15, 2003 09:07
Re: [perl #24202] Perl 5.8.0 regexp anomaly
Message ID:
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.

Ronald Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About