|If there is another function to call before getting the random
|number, please give that to me too (I mean like with visual
|basic, you should use "Randomize" before using "Rnd" to get
|a MUCH random #.
You should use the 'srand' function, which only needs to be called once in your program (before any 'rand' commands). Seed it with something like the classic:
which uses the current time (in seconds since the Epoch) and the PID of the process. Perl, in version 5.004, will actually call srand itself when 'rand' is used and perl does not see a srand. Still, it is always best to call it yourself. For really paranoid ultra-randomness, see Math::TrulyRandom (as well as Math::Random).srand(time ^ $$);
Secondly, what do you mean by decrease the 'usage'? In general, it's actually better to have a single process running, for the abovementioned reasons, as well as others. Consider using 'fork', and having no "start.pl." For low [1] numbers, the system will not really see any difference between 10 people running main.pl, or 10 people each running main1.pl, main2.pl, etc. Either way, it's 10 processes.
[1] In general, you'd need a LOT of users, a very slow CPU, and a very slow, complex script before this really becomes an issue.
In reply to RE: Random Numbers
by turnstep
in thread Random Numbers
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |