in reply to Re^4: File::Random module (Path::Iterator::Rule)
in thread File::Random module
Use the iterator with a while loop and just keep a count (or array) of the number of randomly selected files. Use last when you have enough. Or, if you run out of files, re-generate the iterator.
For what it's worth, you can even put the randomness into the iterator:
my $rule = Path::Iterator::Rule->new->file->and(sub { rand() < 0.1 });
I just shipped PIR 1.005 to CPAN to fix broken tests on Windows.
-xdg
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: File::Random module (Path::Iterator::Rule)
by McA (Priest) on Apr 02, 2013 at 13:45 UTC |