This isn't gonna work. If I want random from 50 - 100, you code puts 50 to 100 in an array then chooses random indexes from 0 - 99. But there are only 51 items in the array. To fix this change your rand parameter from $highest_number to @number_range.
Here's another way:
YuckFoo
#!/usr/bin/perl use strict; my ($beg, $end) = qw(10 20); my $range = ($end - $beg) + 1; for (1..6) { print int(rand($range) + $beg) . "\n"; }
In reply to Re: Re: perl rand() function
by YuckFoo
in thread perl rand() function
by wilstephens
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |