Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Set a process's nice valueRun a separate program (Berikutnya)
Functions for processes and process groups

Block for some number of seconds

Daftar Isi

  • sleep EXPR

  • sleep

    Causes the script to sleep for (integer) EXPR seconds, or forever if no argument is given. Returns the integer number of seconds actually slept.

    May be interrupted if the process receives a signal such as SIGALRM.

    1. eval {
    2. local $SIG{ALARM} = sub { die "Alarm!\n" };
    3. sleep;
    4. };
    5. die $@ unless $@ eq "Alarm!\n";

    You probably cannot mix alarm and sleep calls, because sleepis often implemented using alarm.

    On some older systems, it may sleep up to a full second less than whatyou requested, depending on how it counts seconds. Most modern systemsalways sleep the full amount. They may appear to sleep longer than that,however, because your process might not be scheduled right away in abusy multitasking system.

    For delays of finer granularity than one second, the Time::HiRes module(from CPAN, and starting from Perl 5.8 part of the standarddistribution) provides usleep(). You may also use Perl's four-argumentversion of select() leaving the first three arguments undefined, or youmight be able to use the syscall interface to access setitimer(2) ifyour system supports it. See perlfaq8 for details.

    See also the POSIX module's pause function.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Set a process's nice valueRun a separate program (Berikutnya)