in reply to Re^3: How to know that a regexp matched, and get its capture groups?
in thread How to know that a regexp matched, and get its capture groups?

But...

> See "Performance issues" above for the serious performance implications of using this variable (even once) in your code.

perlvar

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re^4: How to know that a regexp matched, and get its capture groups?
  • Download Code

Replies are listed 'Best First'.
Re^5: How to know that a regexp matched, and get its capture groups?
by LanX (Saint) on Jan 10, 2023 at 12:24 UTC
    OK, I thought this performance issue was resolved for versions newer than 10-15 years.

    Anyway

    ${^MATCH} This is similar to $& ($MATCH) except that it does not incur the perfo +rmance penalty associated with that variable. This variable was added in Perl v5.10.0.

    though I don't understand the /p comment

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

      If you want ${^MATCH} to work in pre-5.20, you need to use /p, which imposes the performance penalty only on the marked regex. On 5.20+, /p is a noop and ${^MATCH} works always, plus all the performance penalties are gone (not tested by me).

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]