Movatterモバイル変換


[0]ホーム

URL:


functions /sleep
(source,CPAN)
You are viewing the version of this documentation from Perl 5.26.1.View the latest version
#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 asSIGALRM.

eval {    local $SIG{ALRM} = sub { die "Alarm!\n" };    sleep;};die $@ unless $@ eq "Alarm!\n";

You probably cannot mixalarm andsleep calls, becausesleep is often implemented usingalarm.

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

For delays of finer granularity than one second, theTime::HiRes module (from CPAN, and starting from Perl 5.8 part of the standard distribution) providesusleep. You may also use Perl's four-argument version ofselect leaving the first three arguments undefined, or you might be able to use thesyscall interface to accesssetitimer(2) if your system supports it. Seeperlfaq8 for details.

See also thePOSIX module'spause function.

Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.

The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.


[8]ページ先頭

©2009-2025 Movatter.jp