There are 2 minor details to be addressed. The rand(1000) function will return float values from 0 and never reaching 1000. So we need to chop off the fractional part - that will yield ints from 0..999. To get the desired range, adding a constant offset of 1 will do the job.
#!/usr/bin/perl use strict; use warnings; print "",int(rand(1000))+1,"\n" for (1..100);
In reply to Re^2: Make random numbers
by Marshall
in thread Make random numbers
by GHMON
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |