Book HomeJava and XSLTSearch this book

8.224. 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().



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.