As mentioned it is hard to read your code, it is long, it does not use strict and warnings, it does not adhere to the smallest possible test case ideal. That said a couple of hints to tidy things up.

It does look like you are taking each business and then comparing all the file entries against it before reading the next business off the array. This means you are reading the input files $number_of_business times. Reading the file is slow, itterating through an array held in memory is fast.

perl -MPOSIX -le'print strftime "%X %x", localtime(time)' 12:28:59 18/03/05
If I missed the boat completely sorry.

Hopefuly this code can give you a couple of ideas ...

#!/usr/bin/perl use warnings; use strict; my @businesses=( ['foo', 'bar', 'baz'], ['een', 'twee', 'drie'], ['ichi', 'ni', 'san'], ['hydrogen', 'helium', 'lithium'], ); my %regexen; foreach my $group (@businesses) { print "making regex from group @{$group} ... "; my $regex=join "|", @$group; print "\\$regex\\\n"; my $compiled_re=qr/$regex/; $regexen{$regex}=$compiled_re; } while (my $line = <DATA>) { for my $group (keys %regexen) { next unless $line =~ /$regexen{$group}/; print "The line $line matched the bussiness group $group\n"; } } __DATA__ nosuch foo this that helium ballon ichi foot een

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

In reply to Re: Reduce the time taken for Huge Log files by Random_Walk
in thread Reduce the time taken for Huge Log files by pr19939

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.