23 May 2020 11:10:24 UTC
- Distribution: WordListRole-RandomSeekPick
- Module version: 0.004
- Source (raw)
- Browse (raw)
- How to Contribute
- Repository (git clone)
- Testers (862 / 0 / 0)
- KwaliteeBus factor: 1
- % Coverage
- License: perl_5
- Activity24 month
- Download (14.1KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionPERLANCAR perlancar
- PROVIDED METHODS
- SEE ALSO
- COPYRIGHT AND LICENSE
WordListRole::RandomSeekPick - Provide a pick() implementation that random-seeks DATA
This document describes version 0.004 of WordListRole::RandomSeekPick (from Perl distribution WordListRole-RandomSeekPick), released on 2020-05-23.
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.
Note: since this role's
pick()operates on the DATA filehandle directly instead of using
each_word(), it cannot be used on dynamic wordlists.
Please visit the project's homepage at https://metacpan.org/release/WordListRole-RandomSeekPick.
Source repository is at https://github.com/perlancar/perl-WordListRole-RandomSeekPick.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=WordListRole-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.
This software is copyright (c) 2020 by firstname.lastname@example.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.
Module Install Instructions
To install WordListRole::RandomSeekPick, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install WordListRole::RandomSeekPick
For more information on module installation, please visit the detailed CPAN module installation guide.