How can I tell Perl to run some code every 20 seconds?
for (;;) { my $start = time; # your code; if ((my $remaining = 20 - (time - $start)) > 0) { sleep $remaining; } }