| Subject: | rand() |
|---|---|
| From: | cybercruiserz@xxxxxxxxx (Bobby) |
| Date: | Mon, 28 Jul 2008 07:54:29 -0700 (PDT) |
| Newsgroups: | perl.beginners |
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";
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | RE: while trying to learn pack, Bob McConnell |
|---|---|
| Next by Date: | Re: rand(), Peng Kyo |
| Previous by Thread: | Pipe print output into shell in debugger, Marek |
| Next by Thread: | Re: rand(), Peng Kyo |
| Indexes: | [Date] [Thread] [Top] [All Lists] |