I want the script to check the file for string "Response Queue Size: 0", and if this string has other than numerical 0, I want this to be print to my screen.

open my $infile, '<', 'C:/Users/katragas/Desktop/apadmin_get_status_lo +g.txt' or die $!; while( <$infile> ) { if( /Response Queue Size: (\d+)/ ) { print unless $1 == 0; } }

Your specification is fairly clear now; you've outlined the criteria. The next step is to implement those criteria:

The code I provided above follows those three steps: The while loop iterates over the file, the 'if' statement looks for a pattern of interest, and the 'print unless' statement prints the line unless that line of interest has a number equal to zero associated with it.


Dave


In reply to Re: I wrote a script to grep by davido
in thread I wrote a script to grep by ksr19742001

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.