${^LAST_SUCCESSFUL_PATTERN}

The last successful pattern that matched in the current scope. The empty pattern defaults to matching to this. For instance:

if (m/foo/ || m/bar/) {
    s//BLAH/;
}

and

if (m/foo/ || m/bar/) {
    s/${^LAST_SUCCESSFUL_PATTERN}/BLAH/;
}

are equivalent.

You can use this to debug which pattern matched last, or to match with it again.

Added in Perl 5.37.10.