Perl random number FAQ: Can you show me some examples of how to get a random number in Perl?
Perl random number - solution
In its simplest form, if you just need a random decimal number between 0 and 1.0, you can use the Perl rand function like this:
# generate a random number in perl with the rand function
my $random_number = rand();
print $random_number, "\n";
When I save this Perl random number code to a file and run it three times, I get these results: