Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL srand Function
Syntax
Definition and Usage
Sets the seed value for the random number generator to EXPR or to a random value based on the time, process ID, and other values if EXPR is omitted.
Return Value
Example
Try out following example:
#!/usr/bin/perl -w
srand(26);
print("Here's a random number: ", rand(), ".\n");
srand(26);
print("Here's the same random number: ", rand(), ".\n");
|
It will produce following result:
Here's a random number: 0.811688061411591.
Here's the same random number: 0.811688061411591.
|
|

|
|
|