How can I create a random number between two numbers in Perl

perl

Solution

my $x = $minimum + int(rand($maximum - $minimum));

http://perldoc.perl.org/functions/rand.html

Note this range excludes `$maximum` itself. Add 1 to make it inclusive.

Problem

I've seen many other ways to do this in other programming languages... Though I havent found one in Perl yet... What I want to accomplish is to set two numbers: ``` $minimum = 100; $maximum = 4000; ``` Then to create a random integer between those two. (whole number) ($random_num) I've looked into this site: http://perlmeme.org/howtos/perlfunc/rand_function.html Which is a good resource, although does not do exactly that.

Original source