in reply to Re^6: trying to implement file tail with regular expression
in thread trying to implement file tail with regular expression
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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: trying to implement file tail with regular expression
by Anonymous Monk on Feb 17, 2016 at 08:11 UTC | |
by poj (Abbot) on Feb 17, 2016 at 08:14 UTC | |
by mkhayat (Initiate) on Feb 17, 2016 at 08:27 UTC | |
by poj (Abbot) on Feb 17, 2016 at 08:33 UTC | |
by mkhayat (Initiate) on Feb 17, 2016 at 08:43 UTC |