On Thu, Aug 28, 2014 at 10:44 AM, Yossi Itzkovich < yossi.itzkov...@ecitele.com> wrote:
> Hi Gabor, > > > > It looks great (especially the last one), but assuming I have just few > components, and the text is big, I guess that restarting regex engine few > times for the same string is a waste of performance, am I right ? > > I guess study() can help here, but I remember reading in the past that > it’s not a good practice to use it. > > > > Yossi > > > You have to try it and see if this part of the code has any impact on the performance of your application. "restarting regex engine" makes it sound like something heavy while it is not really. Especially if your actual regexes are as simple as we had in the example. Ah and all() short-circuts, so if one of the cases fail it won't check all the other cases. (See this example: http://perlmaven.com/does-all-really-short-circuit ) Gabor ps. In every Perl training class I show this slide http://edumaven.com/perl-programming/replace-spaces and explain that the 4th regex, has the exact same performance as the first two together. So I always recommend the first two instead instead of the 4th. They are simpler, less error-prone, and have the same performance.
_______________________________________________ Perl mailing list Perl@perl.org.il http://mail.perl.org.il/mailman/listinfo/perl