in reply to Running subroutines at specific times

Just store this as a queue of arrays, each array containing a sub ref, next timestamp to run the sub, and interval. Then sleep for however many seconds until the next item in the queue is up for running, add interval seconds to the timestamp, requeue, and run the sub. Rinse and repeat. All you need is a priority queue (or heap) module and about 5 minutes of elementary programming.

Of course, if this is an ongoing thing and needs to run 24/7, you may wish to do what blazar suggests and use cron, which was designed specifically for doing this sort of thing.

  • Comment on Re: Running subroutines at specific times