Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Going on tachyon's idea, would it be possible to do something like this?
while (1) { $new_size = -s $file; if ($new_size > $old_size) { # $old_size is defined before this lo +op if ( event_occured() ) { sleep($map_vTime); do_your_thing(); $old_size = $new_size; } $old_size = $new_size; } sleep($normal_sleep_interval); }
I would figure, if the size of your log file changes, then you can easily seek to the point in your file that has changed (you do have the old file size), read the data from it (which should be fast if the new data is small), and decide if your event has indeed occured. If it's not your event, just fall out and go back to your polling. If it is, do your magic.

Hope that helps some.

Update: Not too long after my initial reply, I noticed that BrowserUK posted a much more elegant solution (maybe just a bit overkill?). The general idea still remains the same: check the filesize of your log. YMMV. Good luck.

Theodore Charles III
Network Administrator
Los Angeles Senior High
perl -e "map{print++$_}split//,Mdbnr;"

In reply to Re: 'better mousetrap': how to perform timed event by Necos
in thread 'better mousetrap': how to perform timed event by snafu

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2021-05-16 08:38 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (151 votes). Check out past polls.