I am trying to parse a log file. It's size is about 300KB and when finding some of the items I want I am doing some substitution, but it hangs forever, below is the code I am using to do this. There is a better and faster way to do it? Thanks!

while ( <> ) {
$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";
if (m/iapw_p1/g){s/iapwp1/$p1/g; print;}
if (m/iapw_p2/g){s/iapwp2/$p2/g; print;}
if (m/iapw_p3/g){s/iapwp3/$p3/g; print;}
if (m/iapw_b1/g){s/iapwb1/$b1/g; print;}
if (m/iapw_p0/g){s/iapwp0/$p0/g; print;}
if (m/iapw_c0/g){s/iapwc0/$c0/g; print;}
if (m/iapw_c1/g){s/iapwc1/$c1/g; print;}
if (m/iapw_c2/g){s/iapwc3/$c3/g; print;}
if (m/iapw_c3/g){s/iapwh1/$h1/g; print;}
}

In reply to 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.