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