|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:

srand(time ^ $$);
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).

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.