Perl Language Randomness Generate a random integer between 0 and 9


Example

Cast your random floating-point number as an int.

Input:

my $range = 10;

# create random integer as low as 0 and as high as 9
my $random = int(rand($range));   # max value is up to but not equal to $range

print $random . "\n";

Output:

A random integer, like...

0

See also the perldoc for rand.