note
liverpole
Hi [perl_geoff],
<p>You are trying to compare a list against a scalar in this line:
<c>
if (@logarray eq $error) {
</c>
</p><p>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):
<c>
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;
}
</c>
</p><p>The above will look through each line read in from the file, and print $redbutton or $yellowbutton if the appropriate string is matched.
</p><p>I also did a <c>chomp @logfile</c> to remove the newline from each logfile line, so that the match doesn't have to explicitly declare it.
</p><p>Also, the variable <c>got_button</c> was used so that, when you've gone through all the lines from the file, if the match <i>wasn't</i> found, you know to display the <c>$greenbutton</c>.
</p><p>Hope that helps!
<div class="pmsig"><div class="pmsig-465654">
<hr />
<font size="1">
s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
</font>
</div></div>
585115
585115