in reply to Re: Re: New regex trick...
in thread New regex trick...

Here's the code:
use Benchmark 'cmpthese'; use Regexp::Keep; my $s = "abc.def.ghi.jkl"; cmpthese(-5, { japhy => sub { (my $x = $s) =~ s/.*\K\..*// }, old => sub { (my $x = $s) =~ s/(.*)\..*/$1/ }, });
In 5.6.1:
old = 40280.54/s japhy = 74338.79/s
And with 5.8.0 (using the module, NOT my patch):
old = 58188.18/s japhy = 102409.25/s
So there's an appreciable speed-up.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;