perl -e matching lines between two search patterns - not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dirknrw
    New Member
    • Nov 2008
    • 2

    perl -e matching lines between two search patterns - not working

    Hi,

    I have a tricky question!? :-)

    I'm using the perl -e command in order to match lines between two search patterns. The problem I have is, for the first example it is working, for the second not, but I can't see the difference:

    1) ok:

    [kilian_koala]sharan:~/tmp/koala/nokkcc (171) % perl -ne 'print if /M1000C0/ .. /<\/Counter>/' nokrwwKOALA.xml

    <Counter ID="ave_prxtot_ class_0" OMeSName="M1000 C0" NEName="AVE PRXTOT CLASS 0">
    <Unit>RSSI_LE V</Unit>
    <TimeRawFormula >ROUND((((DECOD E(SUM(PRXTOT_DE NOM_0),0,-112.1,10*LOG(10 ,(SUM(PRXTOT_DE NOM_0*0.001*POW ER(10,((ave_prx tot_class_0/621*62-112.1)/10)))/SUM(PRXTOT_DENO M_0))/0.001)))+112)*6 21/62+1),0)</TimeRawFormula>
    <Description>
    The average PrxTotal in relation to the unloaded area. NOTE: RNC GUI shows the dBm values, not the RSSI_LEV values. UPDATED:When the value for PrxTotal (received by every radio resource indication) is inside Class 0 range.
    </Description>
    </Counter>

    2) Not ok:

    [kilian_koala]sharan:~/tmp/koala/nokkcc (172) % perl -ne 'print if /M1000C1/ .. /<\/Counter>/' nokrwwKOALA.xml | more

    -> endless output (does not stop at the end mark "</Counter>")! ???????

    <Counter ID="prxtot_deno m_0" OMeSName="M1000 C1" NEName="PRXTOT DENOM 0">
    <Unit>No.</Unit>
    <TimeRawFormula >SUM(prxtot_den om_0)</TimeRawFormula>
    <Description>
    Denominator for PrxTotal Class 0 (=Unloaded Area). UPDATED:This counter is incremented by 1 whe
    n PrxTotal (received by every radio resource indication) is inside Class 0 range.
    </Description>
    </Counter>
    <Counter ID="ave_prx_noi se" OMeSName="M1000 C10" NEName="AVE PRX NOISE">
    <Unit>-0.01*dBm</Unit>
    <TimeRawFormula >ROUND((((DECOD E(NVL(SUM(prx_n oise_denom_1),0 ),0,0,10*LOG(10 ,(SUM(prx_noise _denom_
    1*0.001*POWER(1 0,((ave_prx_noi se/100)/10)))/SUM(prx_noise_d enom_1))/0.001))))*100), 0)</TimeRawFormula>
    <Description>
    The average PrxNoise threshold used in admission control. The real dBm value is obtained when d
    ivided by -100. UPDATED:In every radio resource indication period.
    </Description>
    </Counter>
    <Counter ID="prx_noise_d enom_1" OMeSName="M1000 C11" NEName="PRX NOISE DENOM 1">
    <Unit>No.</Unit>
    <TimeRawFormula >SUM(prx_noise_ denom_1)</TimeRawFormula>
    <Description>
    Denominator for average PrxNoise treshold used. UPDATED:In every radio resource indication peri
    od.
    </Description>
    </Counter>
    <Counter ID="max_prx_noi se_value" OMeSName="M1000 C12" NEName="MAXIMUM PRX NOISE VALUE">
    <Unit>-0.01*dBm</Unit>
    <TimeRawFormula >MIN(max_prx_no ise_value)</TimeRawFormula>
    <Description>
    Maximum PrxNoise threshold value. NOTE! Real dBm value is obtained when divided by -100! UPDATE
    D:This counter is updated if the value of the counter is smaller than the current value of PrxNoise thres
    hold.
    </Description>
    </Counter>
    <Counter ID="min_prx_noi se_value" OMeSName="M1000 C13" NEName="MINIMUM PRX NOISE VALUE">
    <Unit>-0.01*dBm</Unit>
    <TimeRawFormula >MAX(min_prx_no ise_value)</TimeRawFormula>
    <Description>
    Minimum PrxNoise threshold value. NOTE2! Real dBm value is obtained when divided by -100! UPDAT
    ED:This counter is updated if the value of the counter is bigger than the current value of PrxNoise thres
    hold.

    ------------------

    can someone see the difference????
    Thx
    dirknrw
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Well, in the second one you piped everything through more ( | more). If they output is endless with that one then it obviously did not work.

    Regards,

    Jeff

    Comment

    • dirknrw
      New Member
      • Nov 2008
      • 2

      #3
      Hi all,

      a fellow of mine found already the answer:

      "M1000C1" string can be found in many lines, therefore many sections are found...

      You need to use the bounderies notation (word bounderies):

      solution for 2) use \b<searchpatter >\b

      [kilian_koala]sharan:~/tmp/koala/nokkcc (193) % perl -ne 'print if /\bM1000C1\b/ .. /<\/Counter>/' nokrwwKOALA.xml
      <Counter ID="prxtot_deno m_0" OMeSName="M1000 C1" NEName="PRXTOT DENOM 0">
      <Unit>No.</Unit>
      <TimeRawFormula >SUM(prxtot_den om_0)</TimeRawFormula>
      <Description>
      Denominator for PrxTotal Class 0 (=Unloaded Area). UPDATED:This counter is incremented by 1 when PrxTotal (received by every radio resource indication) is inside Class 0 range.
      </Description>
      </Counter>

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Glad you found your answer.

        Regards,

        Jeff

        Comment

        Working...