Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Random numbers generation

by PERLscienceman (Curate)
on May 21, 2004 at 19:15 UTC ( #355439=note: print w/ replies, xml ) Need Help??


in reply to Random numbers generation

Greetings Fellow Monk!

Here is yet another way to do what you are asking for using the CPAN Module Math::Random.

#!/usr/bin/perl -w use strict; use Math::Random; my($n,$low,$high)=(100,250,500); my @array=random_uniform_integer($n,$low,$high); for(my $i=0; $i<$n; $i++){print "$array[$i]\n";}
$n is the number of random numbers you wish to generate,
$low is the lower limit, $high is the upper limit, and
@array is the array containing your random numbers as specified by your lower and upper limits.

The beauty of Perl, The Perl Community, and CPAN is that there is usually a module out there that will do just about anything you are looking for often times significantly reducing the amount of code you need to write.


Comment on Re: Random numbers generation
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://355439]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (15)
As of 2015-07-29 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls