Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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 ( [id://11149484]=note: print w/replies, xml ) Need Help??


in reply to Re^4: 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?

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

  • Comment on Re^5: How to know that a regexp matched, and get its capture groups?
  • Download Code

Replies are listed 'Best First'.
Re^6: How to know that a regexp matched, and get its capture groups?
by choroba (Cardinal) on Jan 10, 2023 at 12:30 UTC
    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]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149484]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-19 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found