Let me suggest looking at Math::Random::OO -- particularly Math::Random::OO::UniformInt. (Disclaimer -- I wrote it). It will help avoid typical errors that creep in. (OBO, etc.)
use Math::Random::OO 'UniformInt'; my $prng = UniformInt(1,10); print $prng->next; # integer between 1 and 10 inclusive
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re^2: generating random numbers within a range
by xdg
in thread generating random numbers within a range
by tcf03
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |