in reply to Efficient file handling (was Re^3: trouble parsing log file...)
in thread trouble parsing log file...
Hi, I tried to do this and couldn't get it to work correctly, can you show me what I'm doing 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'>"; open LOG, $logfile or die "Cannot open $logfile for read :$!"; my $button = $greenbutton; my @logfile=<LOG>; # throw logfile into an array while (<LOG>) { if ($_ =~ /$error/i) { $button = $redbutton; print "<!--Content-type: text/html-->\n\n"; print "$button"; last; } elsif ($_ =~ /$warn/i) { $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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Efficient file handling (was Re^3: trouble parsing log file...)
by Not_a_Number (Prior) on Nov 24, 2006 at 18:47 UTC | |
by Anonymous Monk on Jul 05, 2009 at 03:09 UTC |
In Section
Seekers of Perl Wisdom