Perl sleep Function



Description

This function Pauses the script for EXPR seconds, or forever if EXPR is not specified. Returns the number of seconds actually slept. Can be interrupted by a signal handler, but you should avoid using sleep with alarm, since many systems use alarm for the sleep implementation.

Syntax

Following is the simple syntax for this function −

sleep EXPR

sleep

Return Value

This function returns Integer, number of seconds actually slept

Example

Following is the example code showing its basic usage −

#!/usr/bin/perl

$num = 5;
while($num--) {
   sleep(1);
}
perl_function_references.htm
Advertisements