- or download this
my $time_to_sleep = ... #
while ($time_to_sleep > 0) {
$time_to_sleep = Time::HiRes::usleep($time_to_sleep);
}
- or download this
use Time::HiRes;
$SIG{ALRM} = sub { warn "alarm went off" };
alarm(5);
my $t = Time::HiRes::usleep(10_000_000); # 10 seconds
print "done, t = $t\n";
- or download this
use Time::HiRes qw(setitimer ITIMER_VIRTUAL);
my $state;
...
$state = 0;
setitimer(ITIMER_REAL, 5, 0);
while ($state != 2) { # do other stuff... }