in reply to Re: missing second of time
in thread missing second of time
Thanks for the lightbulb. I see no error since doing it that way. I wonder if the perldoc for sleep should add something like:
Explain why this is a subtle trap:
while () {
print something();
sleep 1 # WRONG!
}
Calculate the next second:
use Time::HiRes qw/sleep time/;
while () {
print something();
sleep do { (int time + 1) - time } # RIGHT!
}
Maybe it's already a FAQ? I don't know. Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: missing second of time
by LanX (Saint) on Jan 25, 2020 at 23:11 UTC |