$- is the offset of the start of the last successful match.
] is the offset of the start of the substring matched by n-th subpattern, or undef if the subpattern did not match.
Thus after a match against $_, $& coincides with
substr $_, $-, $+ - $-. 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
This array holds the offsets of the beginnings of the last successful submatches in the currently active dynamic scope.
$- is the offset into the string of the beginning of the entire match. The nth element of this array holds the offset of the nth submatch, so
$- is the offset where $1 begins,
$- the offset where $2 begins, and so on.
After a match against some variable $var: