I would shuffle the list of files and select the first $numOfRandFiles from it, like
use List::Util 'shuffle'; ... (shuffle(@audiofiles))[0 .. $numOfRandFiles - 1];
Note that this generates a list, not a hash.
If you cannot (or don't want to) use a module, you need to reinvent the wheel.
Greetings,
-jo
In reply to Re: Add a fixed number of unique elements to hash
by jo37
in thread Add a fixed number of unique elements to hash
by Vasek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |