while (1) { # Do stuff here; my $next = int((time + 3599)/3600) * 3600; sleep ($next - time); }