Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: How does one get all possible matches from regex?

by 2teez (Priest)
on Dec 10, 2013 at 06:13 UTC ( #1066383=note: print w/replies, xml ) Need Help??

in reply to How does one get all possible matches from regex?

You don't want to be using '$&' in your regex because "..once Perl sees that you need one of $`, $&, or $' anywhere in the program, it provides them for every pattern match. This will slow down your program a bit..." -- Programming Perl
See also:Why does using $&, $`, or $' slow my program down?
Just my 2 kobo advice.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
  • Comment on Re: How does one get all possible matches from regex?

Replies are listed 'Best First'.
Re^2: How does one get all possible matches from regex?
by oiskuu (Hermit) on Dec 10, 2013 at 14:19 UTC
    Is this still a sound advice to give these days? The doc that you link to says:
    As of the 5.005 release, the $& variable is no longer "expensive" the way the other two are.
    Why Is $& Bad? gives a better technical explanation why one might want to avoid $&. Even so, the issue with $& is perhaps more of a concern for core module writers. Can you point to some recent benchmarks?

    On a related note, does study() actually do anything in more recent perls?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1066383]
[james28909]: like all the subs calling get_data get_array get_ect, you could just use get_data. once you send the data to get_data, check if it is a hash or an array ect. and do functions for each, in one sub
[james28909]: that looks like it would be alot more work than just renaming the sub though lol
[Lady_Aleena]: james28909, did you even look at the subs?
[james28909]: yes
[Lady_Aleena]: And you see how the first two are vastly different than the third, right?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2017-05-24 04:58 GMT
Find Nodes?
    Voting Booth?