develooper Front page | perl.perl5.porters | Postings from July 2001

[PATCH perlvar.pod] $^N foolery as well

Thread Previous | Thread Next
From:
Jeff 'japhy/Marillion' Pinyan
Date:
July 26, 2001 17:03
Subject:
[PATCH perlvar.pod] $^N foolery as well
Message ID:
Pine.GSO.4.21.0107261958380.28213-100000@crusoe.crusoe.net
On Jul 26, Jeff 'japhy/Marillion' Pinyan said:

>On Jun 30, Jeffrey Friedl said:
>
>>+so that if the regexp matched, e.g., C<$2> would contain 'cd' or 'ef'. For
>>+convenience, perl sets C<$+> to the string held by the highest numbered
>>+C<$1>, C<$2>, ... that got assigned (and, somewhat related, C<$^N> to the
>>+value of the C<$1>, C<$2>, ... most-recently assigned; i.e. the C<$1>,
>>+C<$2>, ... associated with the rightmost closing parenthesis used in the
>>+match).
>
>Does that make $^N equal to
>
>  substr(???, $-[-1], $+[-1] - $-[-1]);

Hmm, that should be substr(???, $-[-1], $+[$#-] - $-[-1]).  Just in case
my logic with $^N is wrong, I've not included it in the following
patch.  Oh, speaking of the following patch...

I just found gross misinformation in perlvar.pod.  Patch after sig.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **




--- pod/perlvar.pod.old Thu Jul 26 19:58:37 2001
+++ pod/perlvar.pod     Thu Jul 26 20:00:11 2001
@@ -472,10 +472,8 @@
 successful submatches in the currently active dynamic scope.
 C<$-[0]> is the offset into the string of the beginning of the
 entire match.  The I<n>th element of this array holds the offset
-of the I<n>th submatch, so C<$+[1]> is the offset where $1
-begins, C<$+[2]> the offset where $2 begins, and so on.
-You can use C<$#-> to determine how many subgroups were in the
-last successful match.  Compare with the C<@+> variable.
+of the I<n>th submatch, so C<$-[1]> is the offset where $1
+begins, C<$-[2]> the offset where $2 begins, and so on.
 
 After a match against some variable $var:
 


Thread Previous | Thread Next


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