Cari di Perl 
    Perl User Manual
Daftar Isi
(Sebelumnya) Retrieve the natural logarithm ...Return the sine of a number (Berikutnya)
Numeric functions

Retrieve the next pseudorandom number

Daftar Isi

  • rand EXPR

  • rand

    Returns a random fractional number greater than or equal to 0 and lessthan the value of EXPR. (EXPR should be positive.) If EXPR isomitted, the value 1 is used. Currently EXPR with the value 0 isalso special-cased as 1 (this was undocumented before Perl 5.8.0and is subject to change in future versions of Perl). Automatically callssrand unless srand has already been called. See also srand.

    Apply int() to the value returned by rand() if you want randomintegers 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 toolarge or too small, then your version of Perl was probably compiledwith the wrong number of RANDBITS.)

    rand() is not cryptographically secure. You should not relyon it in security-sensitive situations. As of this writing, anumber of third-party CPAN modules offer random number generatorsintended by their authors to be cryptographically secure,including: Data::Entropy, Crypt::Random, Math::Random::Secure,and Math::TrulyRandom.

 
Source : perldoc.perl.org - Official documentation for the Perl programming language
Site maintained by Jon Allen (JJ)     See the project page for more details
Documentation maintained by the Perl 5 Porters
(Sebelumnya) Retrieve the natural logarithm ...Return the sine of a number (Berikutnya)