summaryrefslogtreecommitdiff
path: root/pod/perlvar.pod
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-06-30 12:58:16 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-30 12:58:16 +0000
commita01268b57212e226e8cd71d448590f3e6c10d529 (patch)
treed5af556152a0a5fb6a1171e857700ddebad98f1b /pod/perlvar.pod
parent5511f32566b97bafb11878d78796befdf490138c (diff)
downloadperl-a01268b57212e226e8cd71d448590f3e6c10d529.tar.gz
Add support for $^N, the most-recently closed group.
p4raw-id: //depot/perl@11038
Diffstat (limited to 'pod/perlvar.pod')
-rw-r--r--pod/perlvar.pod21
1 files changed, 18 insertions, 3 deletions
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index eae87c791c..d70f22d1bd 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -180,15 +180,30 @@ performance penalty on all regular expression matches. See L<BUGS>.
=item $+
-The last bracket matched by the last search pattern. This is useful if
-you don't know which one of a set of alternative patterns matched. For
-example:
+The text matched by the last bracket of the last successful search pattern.
+This is useful if you don't know which one of a set of alternative patterns
+matched. For example:
/Version: (.*)|Revision: (.*)/ && ($rev = $+);
(Mnemonic: be positive and forward looking.)
This variable is read-only and dynamically scoped to the current BLOCK.
+=item $^N
+
+The text matched by the used group most-recently closed (i.e. the group
+with the rightmost closing parenthesis) of the last successful search
+pattern. This is primarly used inside C<(?{...})> blocks for examining text
+recently matched. For example, to effectively capture text to a variable
+(in addition to C<$1>, C<$2>, etc.), replace C<(...)> with
+
+ (?:(...)(?{ $var = $^N }))
+
+By setting and then using C<$var> in this way relieves you from having to
+worry about exactly which numbered set of parentheses they are.
+
+This variable is dynamically scoped to the current BLOCK.
+
=item @LAST_MATCH_END
=item @+