in reply to Script Executes Very Slowly
You say there are 200 name-title combinations in @flab and 72,000 lines in the match file. That means that you are executing your foreach loop 1.4 MILLION times (7200 lines x 200 comparisons).
Rewrite your code. Put the 200 entries into a hash keyed by "$name---$title". Then the entire loop collapses in to a single hash-lookup after extracting the fields and building the key.
If you don't want to do such a major restructuring, at least insert last after you print the results. Once you have found the name, you don't need to check any further. Over a large number of searches this will reduce your search time by roughly half. (Making assumptions about normally distributed data, so your results may vary.) Note: This assumes that the 'name' fields are unique. If there can be multiple 'title's attached to the same 'name' you really do have to search the entire @flab array for each line. Sigh.
----
I Go Back to Sleep, Now.
OGB
|
|---|