Your script is a good candidate for dominus' red flag articles :-)
I guess you're better off writing that from scratch. This might give you an idea of an efficient way.
#!/usr/bin/perl use strict; use warnings; use FileHandle; # create a hash of businesses and their target files my %businesses = ( "corp.home.ge.com" => "new_corp_home_ge_com.log", "scotland.gcf.home.ge.com" => "new_scotland_gcf_home_ge_com.log", "marketing.ge.com" => "new_marketing_ge_com.log", ); #loop the data while (<DATA>) { # check if we have a line that contains a http:// address # and store that in $1 #\" is just to prevent editor from screwing syntax higlight if ( m-http://([^/\"]+)- ) { # do we have a entry in the hash for that business if ( $businesses{$1} ) { #yes. so create a filehandle in the hash for writing to th +at unless ( ref $businesses{$1} ) { my $fh = new FileHandle; $fh->open (">$businesses{$1}"); $businesses{$1} = $fh; } #print to the business' filehandle $businesses{$1}->print ($_); } else { #no so emmit a warning warn "unknown business in logfile"; } } } __DATA__ 16/Jan/2005:00:00:40 -0500 "GET /ge/ige/1/1/4/common/cms_portletview2. +html HTTP/1.1" 200 1702 0 "http://marketing.ge.com/portal/site/insura +nce/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" "-" "marke +ting.ge.com" 16/Jan/2005:00:00:40 -0500 "GET /portal/site/transportation/menuitem.8 +c65c5d7b286411eb198ed10b424aa30/ HTTP/1.1" 200 7596 0 "http://geae.ho +me.ge.com/portal/site/transportation/" "Mozilla/4.0 (compatible; MSIE + 5.5; Windows NT 5.0)" "-" "geae.home.ge.com" 16/Jan/2005:00:00:41 -0500 "GET /ge/ige/26/83/409/common/cms_portletvi +ew.html HTTP/1.1" 200 7240 0 "http://marketing.ge.com/portal/site/ins +urance/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" "-" "ma +rketing.ge.com"


Question: Why can't I write
print $businesses{$1} $_; #yields: #Scalar found where operator expected at C:\t.pl line 36, near "} +$_" #(Missing operator before $_?)
??

That's odd.


Update:
Changed the print to the print-method of FileHandle as per castaway's suggestion.


holli, /regexed monk/

In reply to Re: Reduce the time taken for Huge Log files by holli
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.