$ perl -Mstrict -Mwarnings -E ' "abcdef" =~ / .+ (?{say "Matched so far: $&"}) bcdef $/x; ' Matched so far: a