Perhaps try it without tie.
#my $ref = tie *DIAG,"File::Tail",( # name => $Config->{'_'}{'DIAGFILE'}, # interval => 1, # wait at start # maxinterval => 10, # change to suit # adjustafter => 10 # change to suit #); my $fh = File::Tail->new( name => $Config->{'_'}{'DIAGFILE'}, interval => 1, # wait at start maxinterval => 10, # change to suit adjustafter => 10 # change to suit ); my $restart; #while (my $line = <DIAG>) { while (my $line = $fh->read) { print $line; if ($line =~ /is higher than 5 seconds/) { . .
This was the log generator I use to test the script
poj#!perl use strict; my $n = 3; my $s = 10; print "Log generator running .. $n events every $s secs .. \n"; open OUT,'>','c:/temp/diag.log' or die "$!"; select OUT; $|=1; while (1){ print STDOUT scalar localtime."\n"; for (1..$n){ print scalar localtime,"- abc is higher than 5 seconds xyz\n"; } print scalar localtime."- some other log message $_\n" for 0...rand( +10); sleep($s); }
In reply to Re^7: trying to implement file tail with regular expression
by poj
in thread trying to implement file tail with regular expression
by mkhayat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |