Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Random numbers

use strict;
use warnings;

my $num = rand();       # returns a random number: 0 <= NUMBER < 1
my $n   = rand(100);    # returns a number: 0 <= NUMBER < 100
my $i   = int(3.12);    # returns the whole part of the number (3 in this case)

my $number = int(rand(100)); # returns a whole number: 0 <= NUMBER < 100