Here is a task. In Perl, the program needs to obtain an integer random number between N and M.
For example, you need to get a number from
6 as if throwing dice.
In order to do this you need to use the rand()function.
Here is sample code that displays a random number between
6 (also inclusive):
my $number = 1 + int(rand(6));
In general case, if we want to get an integer random number between
$m, then we need
my $n = 1;
my $m = 6;
my $number = $n + int(rand( $m - $n + 1 ));