dbs has asked for the wisdom of the Perl Monks concerning the following question:
will never be executed and if I truncate the $cntrF file the flag will always remain at 1 and thus $cntr will too. So I need a simple way to keep track of how many times -s succeeds (aka an email is sent) for every run of this job over 4 or 5 days which then the flag counter can be set to zero.elsif ( $cntr > 2 ) { for (@p) { ....
thnkU!use strict; use warnings; if ( -s $log ) { $cntr = 0; $flag = 1; open $CF, ">>", $cntrF or die "'$cntrF' did not open $!\n"; print $CF "$flag\n"; sleep 1; close $CF; sleep 1; open $CF, "+<", $cntrF or die "'$cntrF' did not open $!\n"; while (<$CF>) { while (m/\b$flag\b/g) { $cntr++; } } print $cntr; if ( $cntr <= 2 ) { _mailme($alertaddr, $Esubject, $log); $CF->close; } elsif ( $cntr > 2 ) { for (@p) { if ( $_ >= 99 ) { _mailme($alertaddr, $Esubject, $log); last; } } $CF->close; } else { $CF->close; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: best way to....
by SuicideJunkie (Vicar) on Aug 31, 2011 at 18:58 UTC | |
by dbs (Sexton) on Aug 31, 2011 at 20:03 UTC |