Doing things every now and then is a common task, especially in
programs that run for a long time. Some examples: reporting on a
program's status, flushing something to disk, polling something to see
if it has changed, or monitoring or starting processes à la
cron(8).

POE::Kernel's delay() method makes short work of a periodic task.
Simply call it again from the delayed event's handler.

The loss can be avoided altogether by keeping track of the next alarm
time and using alarm() instead of delay. POE's overhead will still
cause some latency between the ideal event time and the actual
dispatch time, but the following program compensates for it.

This one-second timer program keeps the next alarm time in the HEAP
and sets an absolute alarm for that time. Since the next alarm time
increases in a constant fashion, so does the dispatch time.