Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL rand Function



Syntax

rand EXPR

rand


Definition and Usage

Returns a random fractional number between 0 and the positive number EXPR, or 1 if not specified. Automatically calls srand to seed the random number generator unless it has already been called.

Return Value

  • Floating point number

Example

Try out following example:

#!/usr/bin/perl -w

# print a random number between 0 and 10.
print("Random Number:", rand(10), "\n");

It will produce following results:

Random Number:5.09158594141812


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names