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