WordListMod::RandomSeekPick - Provide a pick() implementation that random-seeks DATA
This document describes version 0.001 of WordListMod::RandomSeekPick (from Perl distribution WordListMod-RandomSeekPick), released on 2020-05-22.
use WordListMod qw(get_mod_wordlist); my $wl = get_mod_wordlist("EN::Enable", "RandomSeekPick"); say for $wl->pick(3);
The default WordList's pick() performs a scan on the whole word list once while collecting random items. This role provides an alternative implementation that random-seeks on DATA, discard the line fragment, then get the next line. This algorithm does not provide uniformly random picking, but for many cases it should be random enough. It is faster if you have a huge word list and just want to pick one or a few items.
pick()
Note: since this role's pick() operates on the DATA filehandle directly instead of using each_word(), it cannot be used on dynamic wordlists.
each_word()
Please visit the project's homepage at https://metacpan.org/release/WordListMod-RandomSeekPick.
Source repository is at https://github.com/perlancar/perl-WordListMod-RandomSeekPick.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=WordListMod-RandomSeekPick
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.
File::RandomLine provides a similar algorithm.
WordListMod, WordList xs
perlancar <perlancar@cpan.org>
This software is copyright (c) 2020 by 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.
To install WordListMod::RandomSeekPick, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WordListMod::RandomSeekPick
CPAN shell
perl -MCPAN -e shell install WordListMod::RandomSeekPick
For more information on module installation, please visit the detailed CPAN module installation guide.