Perl srand Function
This function 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
Following is the simple syntax for this function:
srand EXPR srand
This function does not return any value.
Following is the example code showing its basic usage:
#!/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");
When above code is executed, it produced following result
Here's a random number: 0.811688061411591. Here's the same random number: 0.811688061411591.