http://www.perlmonks.org?node_id=586039


in reply to Re^3: trouble parsing log file...
in thread trouble parsing log file...

Hey, I tried using this module, but I'm still running into the same problem as my other script...can you show me where I'm going wrong?
use strict; use warnings; my $logfile="log.txt"; my $error="DOWN"; my $warn="PROBLEM"; my $redbutton="\<img src\=\'default_files/perlredblink\.gif'>"; my $greenbutton="\<img src\=\'default_files/perlgreenblink\.gif'>"; my $yellowbutton="\<img src\=\'default_files/perlyellowblink\.gif'>"; my $button = $greenbutton; # open LOG, $logfile or die "Cannot open $logfile for read :$!"; use File::Tail; tie *LOG, 'File::Tail', (name => $logfile, tail => -1) or die("log open error: $!"); while (my $line = <LOG>) { if ($line eq $error) { $button = $redbutton; print "<!--Content-type: text/html-->\n\n"; print $button; last; } elsif ($line eq $warn) { $button = $yellowbutton; print "<!--Content-type: text/html-->\n\n"; print $button; last; } else { print "<!--Content-type: text/html-->\n\n"; print $button; last; } } close LOG;