in reply to Re^2: trouble parsing log file...
in thread trouble parsing log file...
But it still only displays the green button!$logfile="log.txt"; $error=(/DOWN/); $warn=(/PROBLEM/); $redbutton="\<img src\=\'default_files/perlredblink2\.gif'>"; $greenbutton="\<img src\=\'default_files/perlgreenblink\.gif'>"; $yellowbutton="\<img src\=\'default_files/perlyellowblink\.gif'>"; open LOG, $logfile or die "Cannot open $logfile for read :$!"; @logarray=<LOG>; # dumps all of $logfile into @logarray chomp @logfile; my $got_button = 0; foreach my $line (@logarray) { if ($line eq $error) { $got_button = 1; print $redbutton; last; } elsif ($line eq $warn) { $got_button = 1; print $yellowbutton; last; } } if (not $got_button) { print $greenbutton; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: trouble parsing log file...
by liverpole (Monsignor) on Nov 20, 2006 at 22:06 UTC | |
Re^4: trouble parsing log file...
by SheridanCat (Pilgrim) on Nov 20, 2006 at 22:05 UTC |