[Melbourne-pm] Just how much does $& slow things down?
Toby Corkindale
toby.corkindale at strategicdata.com.au
Thu Nov 20 19:31:38 PST 2008
Alfie John wrote:
> From perlre:
>
> WARNING: Once Perl sees that you need one of $&, $', or $' anywhere in
> the program, it has to provide them for every pattern match.
> This may
> substantially slow your program.
>
> This is the only place in the whole program which uses a regex, so
> the impact on other parts of the program should be nil.
> I just don't know if it's going to be worth removing those
> references to $&, and how much it will benefit the running of the
> program.
> Obviously, the bigger @an_array is, the larger the impact, but I can
> safely say it won't be much bigger than about 50.
> So, are we talking an order of magnitude slower? More? Less? Anybody
> even want to take an educated guess?
>
>
> In other words, having it only in the above code will still impact *all
> other* regexes in any code, including all imported modules.
Do you have to use $&, or can you use ${^MATCH} instead? (Which doesn't
come with the global performance impact)
Toby
--
Strategic Data Pty Ltd
Ph: 03 9340 9000
More information about the Melbourne-pm
mailing list