You are viewing the version of this documentation from Perl blead. This is the main development branch of Perl. (git commit 0a05a8bd231063e1ba6d039754d9e635d47441b5)
${^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.