Copyright © tutorialspoint.com

PERL srand Function


Syntax

srand EXPR

srand


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

  • Nothing

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.

Copyright © tutorialspoint.com