Just looking at the rule checking, I can recommend putting the rules into a hash:
#!/usr/bin/perl -w use strict; # Define substitution rules using a hash. Note that these rules are # stored in no particular order .. if this is very slow, efficiences # can be achieved by changing to an array of hashes, with the most # likely rule checked first. my %Rules = ( "p1" => "P1 = (inquiry, launch page)\n", "p2" => "P2 = (car coverages, endorsements, operators)\n", "p3" => "P3 = (notepad, scratch)\n", "b1" => "B1 = (my inquiry: auto, home and location)", "p0" => "P0 = (local search)\n", "c0" => "C0 = (dist search)\n", "c1" => "C1 = (state inquiry)\n", "c3" => "C3 = (test notepad)\n", "h1" => "H1 = (owners and coop search and history)\n" ); # Process the input stream. while ( <> ) { foreach ( keys %Rules ) { if ( m/iapw_$_/ ) { s/iapw_$_/$Rules{ $_ }/ge; print; # Is there only one possible subsitution per line? If so, # we could use a 'last' statement here to go on to the next # line. } } }

Your logic for opening up the log files is bizarre and does not compile on my system, but I'll presume that you have that part of the operation working correctly.

I can strongly recommend 'Learning Perl' from O'Reilly books. Read through that, try as many examples as you can, and you'll be far better off to tackle Perl projects.

--t. alex

"Mud, mud, glorious mud. Nothing quite like it for cooling the blood!" --Michael Flanders and Donald Swann


In reply to Re: (5) parsing long text file by talexb
in thread parsing long text file by Anonymous Monk

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.