0 down vote favorite I have a text file as below. I need to find keywords as "(number) tests from (number) test cases ran" and store the number. In the below case the number is 67. Secondly, I need to find "PASSED" keyword and then followed by "(number) tests". In the below case it is 67 tests. How can i do it. Thanks, Sharath
< 0x00000: 5b 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 5d 20 31 34 20 [------ +----] 14 < 0x00010: 74 65 73 74 73 20 66 72 6f 6d 20 44 49 53 41 42 tests f +rom DISAB < 0x00020: 4c 45 44 5f 47 65 6e 65 72 69 63 44 52 4d 54 65 LED_Gen +ericDRMTe < 0x00030: 73 74 20 28 31 32 38 34 39 20 6d 73 20 74 6f 74 st (128 +49 ms tot < 0x00040: 61 6c 29 0d 0a 0d 0a 5b 2d 2d 2d 2d 2d 2d 2d 2d al).... +[-------- < 0x00050: 2d 2d 5d 20 47 6c 6f 62 61 6c 20 74 65 73 74 20 --] Glo +bal test < 0x00060: 65 6e 76 69 72 6f 6e 6d 65 6e 74 20 74 65 61 72 environ +ment tear < 0x00070: 2d 64 6f 77 6e 0d 0a 5b 3d 3d 3d 3d 3d 3d 3d 3d -down.. +[======== < 0x00080: 3d 3d 5d 20 36 37 20 74 65 73 74 73 20 66 72 6f ==] 67 +tests fro < 0x00090: 6d 20 34 20 74 65 73 74 20 63 61 73 65 73 20 72 m 4 tes +t cases r < 0x000a0: 61 6e 2e 20 28 34 33 38 32 33 20 6d 73 20 74 6f an. (43 +823 ms to < 0x000b0: 74 61 6c 29 0d 0a 5b 20 20 50 41 53 53 45 44 20 tal)..[ + PASSED < 0x000c0: 20 5d 20 36 37 20 74 65 73 74 73 2e 0d 0a ] 67 t +ests...

In reply to Parsing a text file in Perl. by ramki067

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.