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

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

Jeff 'japhy/Marillion' Pinyan
July 26, 2001 17:03
[PATCH perlvar.pod] $^N foolery as well
Message ID:
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
>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
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?
Perl Programmer at RiskMetrics Group, Inc.
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: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About