Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I'm quite new to perl programming. Here's the problem: I can't get my loop to generate more than 3 random numbers, and I can't figure out why. The command line arguments provide the amount of numbers I want, the minimum and maximum of those values. Here's the important part of code I used:
$n=$ARGV[0]; $a=$ARGV[1]; $b=$ARGV[2]; my $range = $b-$a; for ($i=0,$i<=$n,$i++){ $random_number= int((rand($range)) + $a); print $random_number."\n"; push (@numbers, $random_number); }
appreciate the help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: for loop
by moritz (Cardinal) on Nov 04, 2011 at 09:29 UTC | |
by Anonymous Monk on Nov 04, 2011 at 10:00 UTC |