in reply to generating random blocks of data...

I read somewhere recently (and, of course, I cannot now remember exactly where it was that I read it) that with Perl 5, you do not need to (and should not) use srand;. Does anyone else know the truth value of this assertion?

Replies are listed 'Best First'.
RE: Re: generating random blocks of data...
by plaid (Chaplain) on Feb 25, 2000 at 13:18 UTC
    In perl versions up to 5.003 (I think), srand needed to be called explicitly, but as of 5.004 (again, I think), srand was called implicitly with the first call to rand. Wnen srand is called implicitly however, the seed it is given is a number based on the time, which is predictable, so it's recommended to call it again with a better seed if it's for something more important, like cryptography purposes.
      The results from perldoc -f srand on the latest stable release of perl yield the following results. "In versions of Perl prior to 5.004 the default seed was just the current time(). This isn't a particularly good seed, so many old programs supply their own seed value (often time ^ $$ or time ^ ($$ + ($$ << 15))), but that isn't necessary any more."