This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
srand: change to return its seed
authorKarl Williamson <khw@khw-desktop.(none)>
Tue, 27 Jul 2010 14:18:25 +0000 (08:18 -0600)
committerRafael Garcia-Suarez <rgs@consttype.org>
Wed, 28 Jul 2010 08:07:23 +0000 (10:07 +0200)
commit83832992940e343002e924b1307988d2604ee165
tree6ead241b56a400abd516361b20cf2236859d75c4
parent401a9b146916c60dc9bbd897355c3c83888d61f3
srand: change to return its seed

This commit changes srand to to return the seed instead of always
returning 1.  The motivation behind this is to allow applications to not
have to come up with their own pseudo-random generator if they want
repeatable results.

The previous return behavior has never been documented.  Note that it is
possible, but very unlikely, for the seed to end up being 0, which means
that if someone were relying on the undocumented previous behavior of
srand returning true, that in very rare instances it would return 0,
failing, and the next time they ran it, it would succeed, possibly
leading to puzzlement and very rare unexplained failures.
opcode.h
opcode.pl
pod/perl5134delta.pod
pod/perlfunc.pod
pp.c