I am having a problem with my script reading a directory, file by file; if it finds the word arrer in the file, it will send a page to Mike and go onto the next file. As it is now, if the word is in that file more than once, Mike will be paged for every one. I only want Mike to be paged at the most once per file. How would I do this? Below is my code...it works too well! Mike is being paged 4 times for a file that has this arerr in it 4 times and he should only be paged once. I do not know in advance if the word arrer will exist in these log files or not. If it does exist I will not know how many times it will occur. Here is my code!

use File::Copy; use File::Basename; @errorcheck = glob ('*.log'); my $error = "ARERR"; my $errorcount = 0; foreach $logrecord (@errorcheck) { open (LOGFILE, "$logrecord"); while (<LOGFILE>) { my $logline = $_; if ($logline =~ /$error/) { $errorcount++; } } if ($errorcount ne 0) {system ('page Mike');} } print "$errorcount\n"; close (LOGFILE);

Thanks in advance for any assistance you can give me!!


In reply to A single action from one or more items searched for by rscott212

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.