Re: rand()
- From: cybercruiserz@xxxxxxxxx (Bobby)
- Date: Mon, 28 Jul 2008 09:04:01 -0700 (PDT)
Aruna,
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? Thanks.
--- On Mon, 7/28/08, Aruna Goke <myklass@xxxxxxxxx> wrote:
From: Aruna Goke <myklass@xxxxxxxxx>
Subject: Re: rand()
To: "Perl beginners" <beginners@xxxxxxxx>
Date: Monday, July 28, 2008, 9:54 AM
Bobby wrote:
Hi all,for an array? In the example script below i have an array @nums with a list of
How do I use the rand function to print out more than one random number
numbers; how do i print out more than one random numbers from that list
(@nums)? Thanks.
("10000","10002","10004","10005","10006","140000","1500000");
#!/usr/bin/perl
use strict;
use warnings;
my @nums =
my $randnum = $nums[rand(@nums)];
print "$randnum \n";
#!/usr/bin/perl
use strict;
use warnings;
my @nums =
("10000","10002","10004","10005","10006","140000","1500000");
print "@nums[0..rand(@nums)]\n";
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
- Follow-Ups:
- Re: rand()
- From: John W. Krahn
- Re: rand()
- References:
- Re: rand()
- From: Aruna Goke
- Re: rand()
- Prev by Date: Re: rand()
- Next by Date: Re: rand()
- Previous by thread: Re: rand()
- Next by thread: Re: rand()
- Index(es):
Relevant Pages
|