in reply to Regex combining /(foo|bar)/ slower than using foreach (/foo/,/bar/) ???
Hi,
I think the problem is with this line.
because perl compiles this patern again & again in the foreach loop.my $regex = qr /(?:$regexstr)/;
If you use this patternforeach my $stringlength (100,1000,10000,100000)
instead ofmy $regex = qr /(?:$regexstr)/o;
It will be fast. Since it compiles the pattern only once.my $regex = qr /(?:$regexstr)/;
In Section
Seekers of Perl Wisdom