in reply to trouble parsing log file...
You are trying to compare a list against a scalar in this line:
if (@logarray eq $error) {
What I suspect you want to do instead is to iterate through the list, and break out of the loop when you find the condition you're looking for (note that you don't need to quote variable names to print them):
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; }
The above will look through each line read in from the file, and print $redbutton or $yellowbutton if the appropriate string is matched.
I also did a chomp @logfile to remove the newline from each logfile line, so that the match doesn't have to explicitly declare it.
Also, the variable got_button was used so that, when you've gone through all the lines from the file, if the match wasn't found, you know to display the $greenbutton.
Hope that helps!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: trouble parsing log file...
by liverpole (Monsignor) on Nov 20, 2006 at 20:46 UTC | |
by perl_geoff (Acolyte) on Nov 20, 2006 at 20:58 UTC | |
by liverpole (Monsignor) on Nov 20, 2006 at 22:06 UTC | |
by SheridanCat (Pilgrim) on Nov 20, 2006 at 22:05 UTC | |
by perl_geoff (Acolyte) on Nov 21, 2006 at 15:56 UTC | |
by McDarren (Abbot) on Nov 21, 2006 at 16:04 UTC | |
by perl_geoff (Acolyte) on Nov 21, 2006 at 18:21 UTC | |
by jarich (Curate) on Nov 23, 2006 at 14:41 UTC | |
by perl_geoff (Acolyte) on Nov 28, 2006 at 13:43 UTC | |
Re^2: trouble parsing log file...
by perl_geoff (Acolyte) on Nov 20, 2006 at 20:29 UTC |