Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm sure this has been asked for, so sorry for being redundant. But can someone tell me how to get my script to pause or sleep for increments shorter than one second?

Replies are listed 'Best First'.
Re: sleeping for less than 1 second
by rob_au (Abbot) on Aug 01, 2002 at 00:27 UTC
    You will want to have a look at the Time::HiRes module - This module exports alternate alarm, sleep and time methods which allow timing with a greater level of precision. Additionally, this module provides ualarm and usleep methods for providing such timing precision measured in microseconds.

    See the man page for this module for examples of usage.

     

Re: sleeping for less than 1 second
by greenFox (Vicar) on Aug 01, 2002 at 01:28 UTC
    This is a faq

    "If you want finer granularity than the 1 second that the sleep() function provides, the easiest way is to use the select() function as documented in "select". Try the Time::HiRes and the BSD::Itimer modules (available from CPAN)."

    --
    Until you've lost your reputation, you never realize what a burden it was or what freedom really is. -Margaret Mitchell

Re: sleeping for less than 1 second
by Nightblade (Beadle) on Aug 01, 2002 at 00:10 UTC
    You can effect a sleep of 250 milliseconds this way: select(undef, undef, undef, 0.25);