Re: rand()
- From: jwkrahn@xxxxxxx (John W. Krahn)
- Date: Mon, 28 Jul 2008 11:37:45 -0700
Bobby wrote:
That helps but how would i just get back an X number of random numbers
because @nums could be in the hundreds of unique numbers. For instance,
i just want to randomly pickout 4 numbers from a long list of unique
numbers in @nums, how would i do that?
use List::Util qw' shuffle ';
my $X = 4;
my @random = ( shuffle @nums )[ 0 .. $X - 1 ];
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- References:
- Re: rand()
- From: Bobby
- Re: rand()
- Prev by Date: Re: rand()
- Next by Date: Re: rand()
- Previous by thread: Re: rand()
- Next by thread: Re: rand()
- Index(es):