NAME
Random::Any - Try to use Data::Entropy::Algorithms::rand(), fallback on
builtin rand()
VERSION
This document describes version 0.005 of Random::Any (from Perl
distribution Random-Any), released on 2025-01-07.
SYNOPSIS
use Random::Any qw(rand);
say rand();
DESCRIPTION
This module provides a single export rand() that tries to use
Data::Entropy::Algorithms's rand() first and, if that module is not
available, warns to STDERR and falls back on the builtin rand().
Note that whenever you can you are encouraged to use rand_int() or
random_int(), or rand_flt() or random_float() function instead. From
"Data::Entropy::Algorithm"'s documentation:
"This function should not be used in any new code, because the kind of
output supplied by "rand" is hardly ever the right thing to use. The
"int(rand($n))" idiom to generate a random integer has non-uniform
probabilities of generating each possible value, except when $n is a
power of two. For floating point numbers, "rand" can't generate most
representable numbers in its output range, and the output is biased
towards zero. In new code use "rand_int" to generate integers and
"rand_flt" to generate floating point numbers."
Also, take a look at Random::Simple instead of this module.
EXPORTS
-warn => bool
If true (the default) then emit a warning if Data::Entropy::Algorithms
is not available. To disable this warning, set to false.
FUNCTIONS
rand
ENVIRONMENT
PERL_RANDOM_ANY_WARN
Bool. Can be set to provide default value for "-warn".
HOMEPAGE
Please visit the project's homepage at
<https://metacpan.org/release/Random-Any>.
SOURCE
Source repository is at <https://github.com/perlancar/perl-Random-Any>.
SEE ALSO
Data::Entropy::Algorithms
Random::Simple
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull
requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You
can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally
on your system), you can install Dist::Zilla,
Dist::Zilla::PluginBundle::Author::PERLANCAR,
Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2025 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
BUGS
Please report any bugs or feature requests on the bugtracker website
<https://rt.cpan.org/Public/Dist/Display.html?Name=Random-Any>
When submitting a bug or request, please include a test-file or a patch
to an existing test-file that illustrates the bug or desired feature.