Returns a random fractional number greater than or equal to
0 and less than the value of EXPR. (EXPR should be positive.) If EXPR is omitted, the value
1 is used. Currently EXPR with the value
0 is also special-cased as
1 (this was undocumented before Perl 5.8.0 and is subject to change in future versions of Perl). Automatically calls
srand has already been called. See also
returns a random integer between
9 , inclusive.
(Note: If your rand function consistently returns numbers that are too large or too small, then your version of Perl was probably compiled with the wrong number of RANDBITS.)
rand() is not cryptographically secure. You should not rely on it in security-sensitive situations. As of this writing, a number of third-party CPAN modules offer random number generators intended by their authors to be cryptographically secure, including: Data::Entropy, Crypt::Random, Math::Random::Secure, and Math::TrulyRandom.
© 1993–2016 Larry Wall and others
Licensed under the GNU General Public License version 1 or later, or the Artistic License.
The Perl logo is a trademark of the Perl Foundation.