Perhaps rather than reinventing wheels use AnyEvent and EV to setup a timer event to be posted every second.

$ perl -MTime::HiRes=time -MAnyEvent -E '$quit = AnyEvent->condvar;$w += AnyEvent->timer( after => 1, interval => 1, cb => sub { state $ctr += 1; say "@{[Time::HiRes::time()]}: FOOP! $ctr"; $quit->send if 10 == + $ctr++; } );say qq{Starting loop};$quit->recv;' Starting loop 1574791289.26471: FOOP! 1 1574791290.26702: FOOP! 2 1574791291.26394: FOOP! 3 1574791292.26511: FOOP! 4 1574791293.26735: FOOP! 5 1574791294.26826: FOOP! 6 1574791295.26665: FOOP! 7 1574791296.265: FOOP! 8 1574791297.26659: FOOP! 9 1574791298.26699: FOOP! 10 $

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re: The most precise second (timer) by Fletch
in thread The most precise second (timer) by tukusejssirs

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.