Hello Monks,

I am a seeker of perl wisdom :) Can anyone help on this ? I have following input text:

ABC> LR_PLANE_Y, LRU_SIZE: 128X128, LRU_X: 0, LRU_Y: 0, ABC> Dif: 744374271, Rng: 51464, Cnt: 4, Ret: 1 ABC> LR_FILTER_TYPE: RESTORE_WIENER ABC> Literal: 0 ABC> Literal: 11 ABC> Literal: 14 ABC> Literal: 0 ABC> Literal: 12 ABC> Literal: 3 ABC> WIENER_VFILTER_0: 5, WIENER_VFILTER_1: -19, WIENER_VFILTER_2: +30 ABC> WIENER_HFILTER_0: 5, WIENER_HFILTER_1: -20, WIENER_HFILTER_2: +9 ABC> LR_PLANE_U, LRU_SIZE: 128X128, LRU_X: 0, LRU_Y: 0, ABC> Dif: 525860863, Rng: 38897, Cnt: 0, Ret: 1 ABC> LR_FILTER_TYPE: RESTORE_WIENER ABC> Literal: 2 ABC> Literal: 6 ABC> Literal: 9 ABC> Literal: 7 ABC> WIENER_VFILTER_0: 0, WIENER_VFILTER_1: -2, WIENER_VFILTER_2: 2 +2 ABC> WIENER_HFILTER_0: 0, WIENER_HFILTER_1: 2, WIENER_HFILTER_2: 11 ABC> LR_PLANE_V, LRU_SIZE: 128X128, LRU_X: 0, LRU_Y: 0, ABC> Dif: 66698751, Rng: 59048, Cnt: 9, Ret: 1 ABC> LR_FILTER_TYPE: RESTORE_WIENER ABC> Literal: 14 ABC> Literal: 4 ABC> Literal: 3 ABC> Literal: 5 ABC> WIENER_VFILTER_0: 0, WIENER_VFILTER_1: -22, WIENER_VFILTER_2: +25 ABC> WIENER_HFILTER_0: 0, WIENER_HFILTER_1: -13, WIENER_HFILTER_2: +12

I am doing regex match and detecting this info: LR_PLANE_Y As soon as I detect this I want to print

ABC> LR_FILTER_TYPE: RESTORE_WIENER ABC> WIENER_VFILTER_0: 5, WIENER_VFILTER_1: -19, WIENER_VFILTER_2: +30 ABC> WIENER_HFILTER_0: 5, WIENER_HFILTER_1: -20, WIENER_HFILTER_2: +9

Like this for: LR_PLANE_U This is info:

ABC> LR_FILTER_TYPE: RESTORE_WIENER ABC> WIENER_VFILTER_0: 0, WIENER_VFILTER_1: -2, WIENER_VFILTER_2: 2 +2 ABC> WIENER_HFILTER_0: 0, WIENER_HFILTER_1: 2, WIENER_HFILTER_2: 11

and for :LR_PLANE_V This is info:

ABC> LR_FILTER_TYPE: RESTORE_WIENER ABC> WIENER_VFILTER_0: 0, WIENER_VFILTER_1: -22, WIENER_VFILTER_2: +25 ABC> WIENER_HFILTER_0: 0, WIENER_HFILTER_1: -13, WIENER_HFILTER_2: +12

How can I associate this next filter information, and filter type after detecting a plane? so far I am setting a flag after I detect the plane :

Currently after detecting plane it prints out filter info for all lines.How to make sure first encountered filter info belongs to previously detected plane ?

if ($line =~ /\s*AED>\sLR_PLANE_Y/i){ $y_filter_flag = 1; if ($line =~ /\s*AED>\sLR_FILTER_TYPE:\s(\w+)/i){ #Lr_params_Y +0 if ($1 eq "RESTORE_WINNER") {$y_filt +er_type="01";} } if ($line =~ /\s*WIENER_VFILTER_0:\s(-?\d+),\sWIENER_VFILTER_1:\s(-?\d ++),\sWIENER_VFILTER_2:\s(-?\d+)/i){ ##doing dome manupulation }

Currently after detecting plane it prints out filter info for all lines.How to make sure first encountered filter info belongs to previously detected plane ?


In reply to Print specific data based on regex search in previous line by Eshan_k

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.