in reply to How to speed up multiple regex in a loop for a big data?

One thing that leaps out at me is that you are sorting the keys of %mapper each time you read a record from input_file. Not sure how big a key is, but it might be worth sorting the keys just once before you read input_file, since you don't appear to alter the hash, this should be safe (although I don't know how big a key is). e.g.
my @map_keys = sort keys %mapper;
...
foreach $key (@map_keys) {
...
  • Comment on Re: How to speed up multiple regex in a loop for a big data?

Replies are listed 'Best First'.
Re^2: How to speed up multiple regex in a loop for a big data?
by cdarke (Prior) on May 25, 2006 at 07:06 UTC
    Come to think of it, why are you sorting the keys?
      Hey, you're right!

      I was about to example a case for partial keys getting substituted, but then I realized the keys are wrapped in word boundries, so there's no chance of partial key substitution, and no reason to sort.

      Drop the sort and save some time.
      You are right on unnecessary sorting. I copied over that part from somewhere and wasn't aware of what I was doing...