in reply to Multialarm loop
Or you could just keep an array of phase-time pairs and set an alarm for the next-expiring one:
my @increments = (undef, 30, 300, 30000); my @times = map {($_, time + $increments[$_])} 1..3; alarm($times[0][1]); #... # then in sigalarm, handle and reschedule the next phase my $this_phase = (shift(@times))->[0]; @times = sort { $a->[1] <=> $b[1] } (@times, [$this_phase, $increments +[$this_phase]); alarm($times[0][1]); my_garbage_collect($this_phase);
|
|---|