advice for tailing a file
Daniel Carosone
daniel.carosone at gmail.com
Mon Dec 14 22:26:50 CET 2015
What platform? Linux::Inotify2 and related modules might be a useful
option, especially if the log file is not heavily active.
On 15 Dec 2015 6:20 a.m., "Scott Wiersdorf" <scott at ipartner.net> wrote:
> 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>
>
> _______________________________________________
> anyevent mailing list
> anyevent at lists.schmorp.de
> http://lists.schmorp.de/mailman/listinfo/anyevent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20151215/9faf10b9/attachment.html>
More information about the anyevent
mailing list