Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Regexp string concat

by runrig (Abbot)
on Jun 14, 2004 at 22:33 UTC ( #366721=note: print w/ replies, xml ) Need Help??


in reply to Re: Regexp string concat
in thread Regexp string concat

For a slight speed boost, use compiled regular expressions:

my $string = 'eichenbaumschule'; my @query = qw(baum ums eic chu le); @query = map { qr/($_)/i } @query; $string =~ s/$_/\U$1/g for @query;
(I get ~6000 iterations/sec this way vs. ~3000 your way).

Update: Just realized, this is only a factor if you do the same substitutions multiple times in the same program...if you're only doing this once per run, then you may as well do it delirium's way :-)


Comment on Re^2: Regexp string concat
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://366721]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (15)
As of 2015-07-31 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls