You are viewing the version of this documentation from Perl 5.40.0. View the latest version

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 the pos function returns when called on the variable that was matched against. The nth element of this array holds the offset of the nth 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.