Here is a possible main loop:
my %needed_transaction; while (my %record = get_record()) { if ($record{CALL_INIT} and $record{CHAN_TYPE} =~ /TCH/ ) { $needed_transaction{ $record{TRAN_ID} } = 1; } elsif ($record{CALL_RESPONSE} and $needed_transaction{ $record{TRAN_ID} } ) { output_record(%record); delete $needed_transaction{ $record{TRAN_ID} }; } }
The get_record function should read one block (up to the equals signs) and return a list of key/value pairs. The output_record function should pass along your Px, Py pair. I'll leave those to you to code.

Personally I would pass around anonymous hash references rather than hashes, but I don't know if you know about references. If you want to try that, a good starting point is references quick reference. But as I say, you don't need to go that route to get a working solution.


In reply to Re: Simple log parser I hope! by tilly
in thread Simple log parser I hope! by picabotwo

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.