Perl sleep Function

Advertisements


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);
}

When above code is executed, it produced following result




Advertisements
Advertisements