perl-5.38.0
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.

0 以上 EXPR の値未満の小数の乱数値を返します。 (EXPR は正の数である必要があります。) EXPR が省略されると、1 が使われます。 現在のところ、EXPR に値 0 をセットすると 1 として特別扱いされます (これは Perl 5.8.0 以前には文書化されておらず、将来のバージョンの perl では 変更される可能性があります)。 srand が既に呼ばれている場合以外は、自動的に srand 関数を呼び出します。 srand も参照してください。

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

ランダムな小数ではなく、ランダムな整数がほしい場合は、 rand から返された値に int を 適用してください。 例えば:

    int(rand(10))

returns a random integer between 0 and 9, inclusive.

これは 0 から 9 の値をランダムに返します。

(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 関数が、常に大きい値ばかりや、小さい数ばかりを 返すようなら、お使いになっている Perl が、 良くない 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.

rand は暗号学的に安全ではありません。 セキュリティ的に重要な状況でこれに頼るべきではありません。 これを書いている時点で、いくつかのサードパーティ CPAN モジュールが 作者によって暗号学的に安全であることを目的とした乱数生成器を 提供しています: Data::Entropy, Crypt::Random, Math::Random::Secure, Math::TrulyRandom などです。