@LAST_MATCH_ENDIt doesn't say that it tells you how many capturing parens were successful—rather, how many sets of capturing parens were present in the last successful match. That's consistant with its observed behavior.
@+
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 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.
The docs for @- says that the array element will be undef if the capture paren did not match, which is not claiming that trailing undef entries are deleted from the array.
I'd rather have a clear way to ask for either value than to use sideband information like this.
—John
In reply to Re: Re: Re: Re: What's like $+ but not gives the ordinal?
by John M. Dlugosz
in thread What's like $+ but not gives the ordinal?
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |