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"; }
In reply to Log file tailing by wellsja
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |