my @closed = list_of_files(); my @open = (); my $count = 0; while (1) { my $time = Time::HiRes::time(); check_moved(\@open) if ($count % $CHECKMOVED) == 0; check_new(\@closed) if ($count % $CHECKNEW) == 0; check_read(\@open) if ($count % $CHECKREAD) == 0; ++$count; my $delay = $TICK - (Time::HiRes::time() - $time); Time::HiRes::sleep($delay) if $delay > 0; }