Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2015-10-07 01:24 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (169 votes), past polls