doubleqq:

I didn't bother trying to build sample data to test with, so I'm gonna make a few guesses. Perhaps one or more may be helpful.

First, in your inner loop, you're splitting out the @match array and *then* checking for a regular expression match to decide whether to print a row. I'd suggest checking with the regular expression first, modifying it a little to ensure that it stops at the tab, and capturing the data after the tab for printing, something like this:

foreach my $line (@flab) { if ($line =~ /[^\t]*\Q$sTab[1]\E\t([^\t]+)/) { print RESULT "$sTab[0]\t$sTab[1]\t$2\n"; } }

Next, if you're actually checking for an exact name, rather than using a regular expression, you could just use the eq operator. Even better, if you are checking for an exact name, then you can convert @flab into a hash, and do the lookup by the name:

while (my $sLine = <LONG_LIST>) { chomp $sLine; my ($company, $name) = split /\t/, $sLine; if (exists $flab{$name}) { print RESULT "$company\t$name\t$flab{$name}{TITLE}\n"; } }

If you *do* need to use a regular expression, then you may be better off creating a composite one from your @flab entries. That way you can reduce the number of regular expression searches you actually perform. If you also convert @flab into a hash, then you could do it (something) like:

my $tmp = join("|", keys %flab); my $regex = qr/(?:$tmp)/; while (my $sLine = <LONG_LIST>) { chomp $sLine; if ($sLine =~ $regex) { my ($company, $name) = split /\t/, $sLine; print RESULT "$company\t$name\t$flab{$name}\n"; } }

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Script Executes Very Slowly by roboticus
in thread Script Executes Very Slowly by doubleqq

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.