perl-5.38.0
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.

スクリプトを(整数の) EXPR で指定した秒数 (省略時には、永久に) スリープさせます。 実際にスリープした秒数を返します。

EXPR should be a positive integer. If called with a negative integer, sleep does not sleep but instead emits a warning, sets $! (errno), and returns zero.

EXPR は正の整数である必要があります。 負の整数で呼び出すと、 sleep はスリープせず、 警告を出力して、$! (errno) を設定し、ゼロを返します。

If called with a non-integer, the fractional part is ignored.

If called with a non-integer, the fractional part is ignored. (TBT)

sleep 0 is permitted, but a function call to the underlying platform implementation still occurs, with any side effects that may have. sleep 0 is therefore not exactly identical to not sleeping at all.

sleep 0 は許されていますが、基となるプラットフォーム実装への 関数呼び出しはやはり行われ、どのような副作用も起こり得ます。 従って、sleep 0 は全くスリープしないのと正確に同じではありません。

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

そのプロセスが SIGALRMのようなシグナルを受信すると、 割り込みがかかります。

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

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

sleep は、alarm を使って 実装されることが多いので、alarmsleep は、混ぜて使用することはおそらくできません。

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, the Time::HiRes module (from CPAN, and starting from Perl 5.8 part of the standard distribution) provides usleep. You may also use Perl's four-argument version of select leaving the first three arguments undefined, or you might be able to use the syscall interface to access setitimer(2) if your system supports it. See perlfaq8 for details.

1 秒より精度の高いスリープを行なうには、Time::HiRes モジュール(CPAN から、 また Perl 5.8 からは標準配布されています) が usleep を提供します。 Perl の 4 引数版 select を最初の 3 引数を未定義にして使うか、setitimer(2) をサポートしているシステムでは、 Perl の syscall インタフェースを使って アクセスすることもできます。 詳しくは perlfaq8 を参照してください。

See also the POSIX module's pause function.

POSIX モジュールの pause 関数も参照してください。