I would go about it a little different. I would read your find/replace table into a hash with the find value as the key of the hash. Depending on the amount of memory on your box you are running this with, you may need to tie this has to a file in order to accommodate the data. With find/replace type stuff, I have found better performance with DB_BTREE instead of DB_HASH. Using this approach on a 4 processor 4GB ram server, I have processed close to 12 million an hour. By doing this way you would have something like:
#pseudo code open lookup file while(<lookup>) { chomp; my ($find,$replace)=split /=/; $hash{$find}=$replace; } close lookup open file to work on while(file) { my $field_to_lookup_on=split/unpack whatever if(exists $hash{$field_to_lookup}) { $new_field=$hash{$field_to_lookup}; } else { $new_field=$field_to_lookup_on; } put field back in record print record.
This method does away with looping through arrays and puts it into a little better of a data structure. let me know if this doesn't make sense. kudos. krazken

In reply to Re: Simply Too Slow Find and Replace by krazken
in thread Simply Too Slow Find and Replace by guopan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.