n8ur has asked for the wisdom of the Perl Monks concerning the following question:
So something as simple as:
while (1) { get_data_taking_exactly_55_seconds; sleep(5); write_log_file; }
doesn't cut it; my log entries won't be properly aligned because the data collection function may take a bit more or less than 55 seconds.
What I want to do, I think, is along the lines of:
while (1) { set timer; get_data_taking_55_seconds_give_or_take_a_few; sleep_until_timer_says_60_seconds; write_log_file; }
It seems like using the alarm function to trigger the reading process on receipt of SIGALRM should let me do this but I haven't figured out how to make it work reliably; in particular, I can't figure out what kind of loop structure I need to keep the program alive.
I'd sure appreciate any help on how to implement a "sleep until alarm" capability in my program.
Thanks!
|
|---|