This array holds the offsets of the ends of the last successful match and any matching capture buffers that the pattern contains. (See"Scoping Rules of Regex Variables")
The number of elements it contains will be one more than the number of capture buffers in the pattern, regardless of which capture buffers actually matched. You can use this to determine how many capture buffers there are in the pattern. (As opposed to@-
which may have fewer elements.)
$+[0]
is the offset into the string of the end of the entire match. This is the same value as what thepos
function returns when called on the variable that was matched against. Thenth element of this array holds the offset of thenth 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.
This variable is read-only, and its value is dynamically scoped.
This variable was added in Perl v5.6.0.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.