rand() not so random in perl

You need to use srand to seed the random number generator otherwise it will generate the same number series.

http://perldoc.perl.org/functions/srand.html

Edit:

According to the doc atthe url, if the perl version is before 5.004 then it won't automatically call that function. So check the perl version you're running under.


you can also see String::Random - for generating random strings based on a pattern.


For GOOD random numbers, consider using Math::Random::MT.

Tags:

Perl

Random