Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

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.


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names