Time::HiRes
Provides “high-resolution” functionality for alarm
, sleep
, gettimeofday
, and interval
timers. Ordinarily, Perl deals in
seconds when you use something like sleep()
or alarm()
, with which only positive integers
are allowed. Time::HiRes allows you to use more granular times for
functions such as sleep()
and
alarm()
. For example:
#!/usr/local/bin/perl -w use Time::HiRes qw(usleep); my $ms = 349_000; # That's 349,000 microseconds usleep($ms); print "I'm awake now.\n";
Time::HiRes implements a Perl interface to usleep()
, ualarm()
, gettimeofday()
, setitimer()
, and getitimer()
.
Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.