sleep() function in Perl is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds or forever if parameter is not specified. The sleep( ) function accepts seconds as a parameter and returns the same on success.
Syntax: sleep(seconds)
Returns: seconds passed to it as parameter, on success
Example 1:
print scalar localtime ();
sleep (5);
print "\n" ;
print scalar localtime ();
|
Output:
Thu Mar 28 06:02:21 2019
Thu Mar 28 06:02:26 2019
Example 2:
print scalar localtime ();
sleep ( rand (7));
print "\n" ;
print scalar localtime ();
|
Output:
Thu Mar 28 06:02:26 2019
Thu Mar 28 06:02:27 2019
Last Updated :
07 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...