Can't you just do:

$|= 1; my $next= time() + 60; while( 1 ) { print "\a"; sleep $next-time(); $next += 60; }
There will be a very rare (I'd hope) case of a clock tick happening between the call to time and the call to sleep causing one beep to come one second late, but that won't cause the next beep to slip. When a process goes to sleep, you can't guarantee how fast it will be able to wake up anyway (that is the nature of time-share operating systems).

If that one second turns out to be too much of a problem, then you can use the high-res equivalent:

use Time::HiRes; $|= 1; my( $next, $us )= gettimeofday(); while( 1 ) { print "\a"; $next += 60; usleep tv_interval( [$next,$us], [gettimeofday()] ); }

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Reasonably accurate timing by tye
in thread Reasonably accurate timing by traveler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.