CARVIEW |
Select Language
HTTP/2 200
server: nginx
content-type: text/plain;charset=UTF-8
content-encoding: gzip
content-security-policy: default-src 'self'; connect-src 'self' *.google-analytics.com; img-src 'self' data: www.google-analytics.com www.googletagmanager.com; script-src 'self' 'unsafe-inline' www.google-analytics.com www.googletagmanager.com; style-src 'self'; report-uri /csp-reports
accept-ranges: bytes
age: 0
date: Thu, 31 Jul 2025 06:25:21 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210047-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753943121.604751,VS0,VE647
vary: Accept-Encoding
strict-transport-security: max-age=31557600
content-length: 693
=over
=item rand EXPR
X X
=item rand
Returns a random fractional number greater than or equal to C<0> and B
than the value of EXPR. (EXPR should be positive.) If EXPR is
omitted, the value C<1> is used.
my $num1 = rand(); # Random float at least 0 and below 1
my $num2 = rand(7); # Random float at least 0 and below 7
my $num3 = int(rand(10)); # Random integer at least 0 and below 10
B
=over
=item *
Calling C automatically calls L|/srand EXPR> unless
srand has already been called.
=item *
Currently EXPR with the value C<0> is special-cased as C<1>. This was
undocumented before Perl 5.8.0 and is subject to change in future versions of
Perl.
=item *
As of Perl v5.20.0 C uses the C pseudorandom number generator
to generate random numbers. As a PRNG C should be sufficient for most
non-cryptographic needs. If you need cryptographic random numbers check CPAN
for crypto safe alternatives.
=back
=over
=item B
B 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:
=back
=over
=item * L
=item * L
=back
=back