Bioperl: making a random sequence

Andrew Dalke dalke@acm.org
Tue, 30 May 2000 20:41:18 -0600


Somewhat tangential, but important (I think).  I just spent time
today documenting this problem on a project I'm working on.

 Dave Campbell  said:
[description of using rand with and without srand]

>Third try, call srand( time() ^ ($$ + ($$ << 15)) ): # As recommended in
>the camel book.


If you read perlfunc, it says that (perl5) pre-5.004 when rand is
called and srand has not been called then the current time is used.
5.004 changed the default seed to be either:
  1) from /dev/random, if available, otherwise
  2) a combination of time(), $$ and "a few" other variables.  It doesn't
describe what those are and I haven't read the source yet.

If someone is doing an software attack on your software and can look
at the process table, then it's relatively easy to guess the srand you
quoted from the camel book.  (You'll only need a few hundred tries.)

For this case it isn't important, but it's something people often
forget.

Lemme think of some biology to add.... Nope, sorry, can't think of
anything interesting :(

                    Andrew
                    dalke@acm.org


=========== Bioperl Project Mailing List Message Footer =======
Project URL: http://bio.perl.org/
For info about how to (un)subscribe, where messages are archived, etc:
http://www.techfak.uni-bielefeld.de/bcd/Perl/Bio/vsns-bcd-perl.html
====================================================================