Quick and dirty solution using a state variable:
use strict; use warnings; my $flag = 0; while (<DATA>) { if (/^CHAN_TYPE\s+TCH/) { $flag = 1 } if ($flag) { if (/Px,Py/) { print; $flag = 0; } } } __DATA__
============================================== CALL_INIT 2008/09/08 15:21:56.958 TRAN_ID deadbeeffe3 CGI 310-26-1-1 CHAN N/A CHAN_MODE Speech Version 2 (EFR) CHAN_TYPE TCH/EFR SUB_CHAN 0 TIMESLOT 3 TSC 4 HOPPING Enabled MAIO 0 HSN 0 MA 528,529,530,531,532,533,534,542,543,544,545 ENCR N/A SESSION_KEY N/A RESPONSE_TIME 20000 ms ============================================== CALL_RESPONSE 2008/09/08 15:21:59.223 TRAN_ID deadbeeffe3 CGI 310-26-1-1 PLR_RESPONSE_TIME 20000 ms Px,Py = bfbc76e04a8768e2,3faca2020f5a215b UNCERTAINTY MAJOR 0x2 (2 m) UNCERTAINTY MINOR 0x2 (2 m) CONFIDENCE 70 % TYPE OF SHAPE 3 LOCATION METHOD 8 ============================================== ============================================== CALL_INIT 2008/09/08 15:21:56.958 TRAN_ID deadbeeffe3 CGI 310-26-1-1 CHAN N/A CHAN_MODE Speech Version 2 (EFR) CHAN_TYPE FOO SUB_CHAN 0 TIMESLOT 3 TSC 4 HOPPING Enabled MAIO 0 HSN 0 MA 528,529,530,531,532,533,534,542,543,544,545 ENCR N/A SESSION_KEY N/A RESPONSE_TIME 20000 ms ============================================== CALL_RESPONSE 2008/09/08 15:21:59.223 TRAN_ID deadbeeffe3 CGI 310-26-1-1 PLR_RESPONSE_TIME 20000 ms Px,Py = 00000000000000000,00000000000000000000 UNCERTAINTY MAJOR 0x2 (2 m) UNCERTAINTY MINOR 0x2 (2 m) CONFIDENCE 70 % TYPE OF SHAPE 3 LOCATION METHOD 8 ==============================================

prints:

Px,Py = bfbc76e04a8768e2,3faca2020f5a215b

In reply to Re: Simple log parser I hope! by toolic
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.