advice for tailing a file
Scott Wiersdorf
scott at ipartner.net
Mon Dec 14 20:20:24 CET 2015
On Mon, Dec 14, 2015 at 10:32:26AM -0700, Scott Wiersdorf wrote:
> I'm pretty sure now that File::Tail won't work for me since I will
> need to be doing things every n seconds and I can't be blocking on
> disk I/O.
My mistake: it looks like File::Tail supports a 'nowait' option, so
now I can set a recurring AE timer and go into a loop to read the IO:
my $tail = File::Tail->new(name => $f, nowait => 1, ...);
my $timer = AE::timer ...
while(1) {
if (my $line = $tail->read) {
## do something with line
}
EV::run EV::RUN_ONCE;
}
Does this seem sane? It appears to be working, but I don't know if
there lurk any gotchas.
Scott
--
Scott Wiersdorf
<scott at perlcode.org>
More information about the anyevent
mailing list