Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

random numbers 1

Status
Not open for further replies.

m52

Programmer
Aug 11, 1999
5
AU
I need to get a series of random numbers which are alldifferant to each other, in a given range. However i need my script to return the same series of random numbers given the same information passed from a form.<br>
Thanks
 
What kind of information is passed from the form?<br>
<br>
Mike<br>
---<br>
Mike_Lacey@Cargill.Com
 
The form passes the day, month, year, a lucky number and a lucky word, so on a given day the user should be able to enter the same word and number and get the same random numbers.<br>
Thanks
 
Ok. Look in the perlfunc man page for the srand function - this starts off the perl random number generator at a certain point.<br>
<br>
Think of the date as a number like this: 19993108<br>
<br>
and a word as a series of numbers - the ascii value of those characters - add all these values together.<br>
<br>
Add the date number to the value you got from adding the ascii values of the lucky word (and your lucky number) and use that result to initialise (to "seed" - they call it) the random number generator.<br>
<br>
That should give you a starting point.<br>
<br>
Interesting. People normally want to know how make thier "random" series of numbers *truly* random - much more difficult.<br>
<br>
Regards<br>
<br>
Mike<br>
---<br>
Mike_Lacey@Cargill.Com<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top