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?