in reply to Top of the second?

On linux, this always shows a time ending in 0:
my $PERIOD = 10; while (1) { my $mod = time % $PERIOD; sleep $PERIOD - $mod; print scalar localtime, "\n"; }
Try something like that.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
(tye)Re2: Top of the second?
by tye (Sage) on Mar 22, 2001 at 02:06 UTC

    This (mostly) works as long as your sleep metronome and time of day clock are in sync and your system isn't busy enough to cause too much delay between execution of the different lines of code. Not always true:

    Sleep metronome: | | | | | | Time of day: | 07 | 08 | 09 | 10 | 11 | 12 | A B C A: time=...09 $mod=9 B: sleep 10-9 C: localtime=...:09

    You can see lots of ways to move points around on that drawing to get different results as well.

            - tye (but my friends call me "Tye")
      Yeah, so at worst, it sleeps to 01, which is not a problem because you might not have been swapped in until 01 anyway. {grin}

      -- Randal L. Schwartz, Perl hacker