wellsja has asked for the wisdom of the Perl Monks concerning the following question:
use IO::Select; $select = IO::Select->new(); # repeat next two lines for all filehandles to poll open(LOGFILE, "< james.log") || die; seek(LOGFILE, 0, 2); $select->add(*LOGFILE); for (;;) { if (@ready = $select->can_read) { # input waiting on the filehandles in @ready foreach $filehandle (@ready) { while (<$filehandle>) { chomp(); if (m/^Hello/) { print STDERR "This is a hello msg"; $starttime = time; } } } sleep 2; $endtime = time; print STDERR "$starttime\n"; print STDERR "$endtime\n"; } } $timediff = $endtime - $starttime; if ( $timediff = "60" ) { print STDERR "Have not recieved a message in the last + $timediff seconds"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Log file tailing
by matija (Priest) on May 17, 2004 at 09:27 UTC | |
by wellsja (Novice) on May 17, 2004 at 09:41 UTC | |
|
Re: Log file tailing
by rinceWind (Monsignor) on May 17, 2004 at 09:54 UTC | |
by matija (Priest) on May 18, 2004 at 05:28 UTC | |
|
Re: Log file tailing
by ysth (Canon) on May 17, 2004 at 08:41 UTC | |
by wellsja (Novice) on May 17, 2004 at 08:51 UTC | |
|
Re: Log file tailing
by McMahon (Chaplain) on May 17, 2004 at 15:26 UTC | |
|
Re: Log file tailing
by tachyon (Chancellor) on May 18, 2004 at 04:38 UTC |