Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: srand and seed

by japhy (Canon)
on Oct 23, 2001 at 03:54 UTC ( [id://120660]=note: print w/replies, xml ) Need Help??


in reply to srand and seed

Calling srand() sets up the seed for the random number generator. Calling rand() then returns a random number in the sequence denoted by the seed.
srand 10; $x = rand; srand 10; $y = rand;
In that code, $x and $y will hold the same value. That is why YOUR code produces 11 identical values. Specifically, it runs so fast that time() never changes.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-18 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found