You are viewing the version of this documentation from Perl blead. This is the main development branch of Perl. (git commit 7550d0c6e95d9645f94db47f1829bafd8a4c3dd9)
$LAST_PAREN_MATCH
$+

The text matched by the highest used capture group of the last successful search pattern. (See "Scoping Rules of Regex Variables"). It is logically equivalent to the highest numbered capture variable ($1, $2, ...) which has a defined value.

This is useful if you don't know which one of a set of alternative patterns matched. For example:

if (/Version: (.*)|Revision: (.*)|Release: (.*)/) {
    $rev = $+;
    # like $rev = $3 // $2 // $1;
}

This variable is read-only, and its value is dynamically scoped.

Mnemonic: be positive and forward looking.