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