Note that having the timeout in can_read is actually essential, or else when nothing is writing to the file you'll never return from the can_read call - this means you won't generate the message unless you follow this advice and add a timeout to can_read.

Of course, if you're already putting a timeout in the can_read call anyway, why not go all the way and just put the 60 second timeout in there? Something like this:

for (;;) { if (@ready = $select->can_read(60)) { # input waiting on the filehandles in @ready foreach $filehandle (@ready) { while (<$filehandle>) { chomp(); if (m/^Hello/) { $log->error("This is a hello msg"); } else { $log->error("message was not recieved"); } } } } else { $log->error("No new messages in the last 60 seconds"); } }

Now, this does mean that your "every 10 seconds" idea has gone away, but it was never really there in the first place - as I mentioned before, can_read will block forever if you don't give it a timeout, and this code won't be running your cpu time through the roof because can_read will block, up to the given timeout interval.

As someone else mentioned, though, look at File::Tail and see if it can do the hard stuff for you.

-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

In reply to Re: Re: Logging question by fizbin
in thread Logging question by wellsja

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.