As we all know, Perl's core sleep() only likes integers. There are, however, many places where one would like to sleep for under a second, or for periods other than what can be expressed with normal integers.
There are a few different ways to do it, and the most common ways I've seen are Time::HiRes::sleep($n) or Time::HiRes::usleep($n * 1_000_000) (which, obviously, require Time::HiRes) and select(undef, undef, undef, $n).
Are the different ways of sleeping just a personal preference, or are there some real differences (Memory/CPU usage, accuracy, ...)?
And, finally, what do you use to sleep? Personally, I've always used Time::HiRes::sleep since it's what I used the first time I needed to sleep for a split-second, and the habit just stuck then. :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.