Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: missing second of time

by stevieb (Canon)
on Jan 25, 2020 at 17:41 UTC ( [id://11111884]=note: print w/replies, xml ) Need Help??


in reply to Re: missing second of time
in thread missing second of time

Nice. Here's a way using select(), so that there's no need for non-core modules (ie. Time::Hires):

use strict; use warnings; my $fudgefactor = 0.01; while (1) { my $nextsecond = int time + 1; select(undef, undef, undef, $nextsecond - time - $fudgefactor); 1 while time < $nextsecond; printf "%.6f\n", time; }

Output:

1579973997.000000 1579973998.000000 1579973999.000000 1579974000.000000 1579974001.000000 ^C

Replies are listed 'Best First'.
Re^3: missing second of time
by davido (Cardinal) on Jan 25, 2020 at 22:53 UTC

    Time::HiRes is core Perl, as much as strict.

    $ corelist Time::HiRes Data for 2020-01-20 Time::HiRes was first released with perl v5.7.3

    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11111884]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found