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