in reply to Running subroutines at specific times

Seems like an event driven thing... but do you want the code in the various subs to run asynchronously? Can it possibly last more than the given amount of time? if so then you {c,sh}ould fork or use threads. Else you may be interested in alarm.

All in all seems more like stuff for cron. In perl, you may just have an infinite loop with a sleep 1 holding a counter. If, say, $counter % $interval == 0 then this will trigger the wanted action. Of course you can and probably want to have @interval or %interval instead of $interval.

Replies are listed 'Best First'.
Re^2: Running subroutines at specific times
by stellagoddc (Novice) on May 11, 2006 at 16:56 UTC
    Blazar,

    I think that might just do it.

    Thanks a lot

Re^2: Running subroutines at specific times
by stellagoddc (Novice) on Apr 20, 2006 at 17:16 UTC
    Thanks, let me add a little more detail.

    I currently have a script which fires of a load of threads, to do SNMP polls on particular devices, each poll getting its own thread. I dont want to have a thread per device constantly running, especially if all its doing is sleeping.

    So I suppose what I'm after is the ability to fire the same routine of (as a thread) every 20 seconds for device A, every 30 seconds for device B etc.

    I was planning on reading in the device -> polling rate realtionship from a file. So it has to be a little dynamic.

    Thanks again.