in reply to 'better mousetrap': how to perform timed event
Going on tachyon's idea, would it be possible to do something like this?
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
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"
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.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); }
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
email->secon_kun@hotmail.com
perl -e "map{print++$_}split//,Mdbnr;"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: 'better mousetrap': how to perform timed event
by snafu (Chaplain) on Apr 25, 2003 at 23:44 UTC |
In Section
Seekers of Perl Wisdom