Using Perl, without using any extra modules that don’t come with ActivePerl, how can I create a string of 8 characters from 0-F. example 0F1672DA? The padding should be controllable and exactly 8 characters is preferable.
More examples of the kinds of strings I would like to generate:
28DA9782
55C7128A
In principle, you ought to be able to do
However, you may find out that —at least on some systems with some
perls (if not all)— the range ofrandis restricted to 32,768 values.You can also study the source code of String::Random to learn how to generate random strings satisfying other conditions.
However, my caution against using the built in
randon Windows system still stands. See Math::Random::MT for a high quality RNG.PS: The issue with Perl’s rand on Windows was fixed in 5.20: