Adam has asked for the wisdom of the Perl Monks concerning the following question:
Well, I looked at that and said to my self, "That would look nicer if the seconds field was just 00." So I tried:bash-2.02$ perl -e '{warn scalar localtime,$/;sleep 60;redo}' Wed Mar 21 10:27:12 2001 Wed Mar 21 10:28:12 2001 Wed Mar 21 10:29:12 2001 ^C
That through me for a bit of a loop, and I thought about it and remembered that sleep is imprecise.bash-2.02$ perl -e 'while(time%60){}{warn scalar localtime,$/;sleep 60 +;redo}' Wed Mar 21 10:39:00 2001 Wed Mar 21 10:39:59 2001 Wed Mar 21 10:40:59 2001 Wed Mar 21 10:41:59 2001 ^C
But what I don't understand, and perhaps someone can enlighten me, is why "top of the second" would round down like that, instead of up. Either I don't understand the phrase, or on some older systems it is just a different behaviour. The system, by the way, is running SunOS 5.7. Also, why didn't it drift before I added the initialization? I thought that maybe the initialization was putting it on the edge, so I added a select statement to pause it for an additional tenth of a second, and ten minutes later it had drifted off again. This leads me to think that the system clock it-self might be at fault. Ideas? Insights?bash-2.02$ perl -e '{while(time%60){}warn scalar localtime,$/;sleep 59 +;redo}' Wed Mar 21 10:58:00 2001 Wed Mar 21 10:59:00 2001 Wed Mar 21 11:00:00 2001 Wed Mar 21 11:01:00 2001 ^C
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: Top of the second?
by tye (Sage) on Mar 22, 2001 at 01:28 UTC | |
|
Re: Top of the second?
by AgentM (Curate) on Mar 22, 2001 at 02:28 UTC | |
|
Re: Top of the second?
by merlyn (Sage) on Mar 22, 2001 at 01:45 UTC | |
by tye (Sage) on Mar 22, 2001 at 02:06 UTC | |
by merlyn (Sage) on Mar 22, 2001 at 02:26 UTC | |
|
Re: Top of the second?
by Anonymous Monk on Mar 22, 2001 at 01:44 UTC | |
by Adam (Vicar) on Mar 22, 2001 at 03:08 UTC |