The Wayback Machine - https://web.archive.org/web/20151221043003/http://perldoc.perl.org:80/functions/rand.html

Perl version

Modules

  • ABCDE
  • FGHIL
  • MNOPS
  • TUX

rand

Perl 5 version 22.0 documentation

Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled, or are running a non-JavaScript capable web browser.

To get the best experience, please enable JavaScript or download a modern web browser such as Internet Explorer 8, Firefox, Safari, or Google Chrome.

Recently read

rand

  • rand EXPR

  • rand

    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 unless srand has already been called. See also srand.

    Apply int() to the value returned by rand() if you want random integers instead of random fractional numbers. For example,

    1. int(rand(10))

    returns a random integer between 0 and 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.

 
Morty Proxy This is a proxified and sanitized view of the page, visit original site.