Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# sleep

Perl 5 version 10.1 documentation
Go to top

# sleep

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- sleep EXPR

- sleep

  Causes the script to sleep for EXPR seconds, or forever if no EXPR. Returns the number of seconds actually slept.

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

          eval {        local $SIG{ALARM} = 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`.

  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.

  See also the POSIX module's `pause` function.

Recently read

Tools

- Preferences