in reply to Re: What is the best way to run periodic tasks (once per minute)?
in thread What is the best way to run periodic tasks (once per minute)?
#!/usr/bin/perl use strict; my $interval = 60; # seconds between calls + # sub will be called every $interval seconds my $process = sub { print "processing!\n" }; + # engage the alarm system $SIG{ALRM} = sub { &$process; alarm $interval; }; + alarm $interval; + # function will be called every 60 seconds for rest of program...
Another alternative would be to upgrade the program to use POE events. This would be the route I would take. The alarm demo is more for historical interest and fiddling than for anything else.
|
|---|