Perldoc Search: "$+" perl-5.20.1

search official POD


7 PODs, 31 LINEs found.
perlvar.pod
414 :             substr($str, $-[0], $+[0]-$-[0]),
415 :             substr($str, $+[0]);
505 :     $+      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:
507 :                 /Version: (.*)|Revision: (.*)/ && ($rev = $+);
527 :     @+      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 *n*th element of this array holds the offset of the *n*th submatch, so $+[1] is the offset 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 successful match. See the examples given for the "@-" variable.
534 :             For example, $+{foo} is equivalent to $1 after the following match:
551 :             Thus, after a match against $_, $& coincides with "substr $_, $-[0], $+[0] - $-[0]". Similarly, $*n* coincides with "substr $_, $-[n], $+[n] - $-[n]" if $-[n] is defined, and $+ coincides with "substr $_, $-[$#-], $+[$#-] - $-[$#-]". One can use $#- to find the last matched subgroup in the last successful match. Contrast with $#+, the number of subgroups in the regular expression. Compare with "@+".
558 :             $& is the same as "substr($var, $-[0], $+[0] - $-[0])"
559 :             $' is the same as "substr($var, $+[0])"
560 :             $1 is the same as "substr($var, $-[1], $+[1] - $-[1])"
561 :             $2 is the same as "substr($var, $-[2], $+[2] - $-[2])"
562 :             $3 is the same as "substr($var, $-[3], $+[3] - $-[3])"
perlre.pod
406 :     Capture group contents are dynamically scoped and available to you outside the pattern until the end of the enclosing block or until the next successful match, whichever comes first. (See "Compound Statements" in perlsyn.) You can refer to them by absolute number (using "$1" instead of "\g1", etc); or by name via the "%+" hash, using "$+{*name*}".
422 :              and print "'$+{char}' is the first doubled character\n";
447 :     Several special variables also refer back to portions of the previous match. $+ returns whatever the last bracket match matched. $& returns the entire matched string. (At one point $0 did also, but now it returns the name of the program.) $` returns everything before the matched string. $' returns everything after the matched string. And $^N contains whatever was matched by the most-recently closed group (submatch). $^N can be used in extended patterns (see below), for example to assign a submatch to a variable.
580 :           say $+ {a};   # Prints '12'
581 :           say $+ {b};   # *Also* prints '12'.
616 :         If multiple distinct capture groups have the same name then the $+{NAME} will refer to the leftmost defined group in the match.
624 :         $+{foo} will be the same as $2, and $3 will contain 'z' instead of the opposite which is what a .NET regex hacker might expect.
869 :         Note that capture groups matched inside of recursion are not accessible after the recursion returns, so the extra layer of capturing groups is necessary. Thus $+{NAME_PAT} would not be defined even though $+{NAME} would be.
perlretut.pod
397 :     For convenience, Perl sets $+ to the string held by the highest numbered $1, $2,... that got assigned (and, somewhat related, $^N to the value of the $1, $2,... most-recently assigned; i.e. the $1, $2,... associated with the rightmost closing parenthesis used in the match).
448 :                 print "day=$+{d} month=$+{m} year=$+{y}\n";
470 :     In addition to what was matched, Perl also provides the positions of what was matched as contents of the "@-" and "@+" arrays. $-[0] is the position of the start of the entire match and $+[0] is the position of the end. Similarly, $-[n] is the position of the start of the $n match and $+[n] is the position of the end. If $n is undefined, so are $-[n] and $+[n]. Then this code
475 :             print "Match $exp: '${$exp}' at position ($-[$exp],$+[$exp])\n";
494 :         $& is the same as substr( $x, $-[0], $+[0]-$-[0] )
495 :         $' is the same as substr( $x, $+[0] )
perlreref.pod
252 :        $+    Last parenthesized pattern match
256 :        @+    Offsets of ends of groups. $+[0] holds end of whole match
perlreapi.pod
402 :             U32 lastparen;            /* highest close paren matched ($+) */
perllocale.pod
460 :         The matched-pattern variables, $&, $` (pre-match), $' (post-match), and $+ (last match) also are tainted.
perlrecharclass.pod
389 :         The similarly named property, "\p{Punct}", matches a somewhat different set in the ASCII range, namely "[-!"#%&'()*,./:;?@[\\\]_{}]". That is, it is missing the nine characters "[$+<=>^`|~]". This is because Unicode splits what POSIX considers to be punctuation into two categories, Punctuation and Symbols.
<< Back to Perldoc Search