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 <[EMAIL PROTECTED]> wrote:

From: Aruna Goke <[EMAIL PROTECTED]>
Subject: Re: rand()
To: "Perl beginners" <beginners@perl.org>
Date: Monday, July 28, 2008, 9:54 AM

Bobby wrote:
> Hi all,
>  
> How do I use the rand function to print out more than one random number
for an array? In the example script below i have an array @nums with a list of
numbers; how do i print out more than one random numbers from that list
(@nums)? Thanks. 
>  
> #!/usr/bin/perl
> use strict;
> use warnings;
> my @nums =
("10000","10002","10004","10005","10006","140000","1500000");
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


      

Reply via email to