in reply to The most precise second (timer)
Just save the value and test before sleeping.
use strict; use warnings; use Time::HiRes qw/time sleep/; sub negative_timer { my $max = $_[0]; my @time_test; my $start = time(); for (my $i = 0; $i < $max; $i++) { $start += 1; my $dt = $start - time(); if ($dt > 0) { sleep $dt; $time_test[$i] = time(); } } return @time_test; }
Good Day,
Dean
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: The most precise second (timer)
by tukusejssirs (Beadle) on Nov 26, 2019 at 15:29 UTC |
In Section
Seekers of Perl Wisdom