Acme-CPANModules-PickingRandomLinesFromFile

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        works by random seeking the file, discarding the line fragment
        (a.k.a. searching forward for the next newline character), reading
        the next line, then repeating the process until the desired number
        of lines is reached. This means one doesn't have to read the whole
        file and the picking process is much faster than the scan method. It
        might be preferred for very large files.

        Note that due to the nature of the algorithm, lines are weighted by
        the number of characters. In other words, lines that have long lines
        immediately preceding them will have a greater probability of being
        picked. Depending on your use case or the line length variation of
        your file, this algorithm might or might not be acceptable to you.

    File::Random::Pick
        Author: PERLANCAR <https://metacpan.org/author/PERLANCAR>

        This module is an alternative to File::Random. It offers a
        "random_line()" routine that avoids duplication.

    App::PickRandomLines
        Author: PERLANCAR <https://metacpan.org/author/PERLANCAR>

lib/Acme/CPANModules/PickingRandomLinesFromFile.pm  view on Meta::CPAN

The second algorithm is more interesting: it works by random seeking the file,
discarding the line fragment (a.k.a. searching forward for the next newline
character), reading the next line, then repeating the process until the desired
number of lines is reached. This means one doesn't have to read the whole file
and the picking process is much faster than the scan method. It might be
preferred for very large files.

Note that due to the nature of the algorithm, lines are weighted by the number
of characters. In other words, lines that have long lines immediately preceding
them will have a greater probability of being picked. Depending on your use case
or the line length variation of your file, this algorithm might or might not be
acceptable to you.

_
        },
        {
            module => 'File::Random::Pick',
            description => <<'_',

This module is an alternative to <pm:File::Random>. It offers a `random_line()`
routine that avoids duplication.

lib/Acme/CPANModules/PickingRandomLinesFromFile.pm  view on Meta::CPAN

The second algorithm is more interesting: it works by random seeking the file,
discarding the line fragment (a.k.a. searching forward for the next newline
character), reading the next line, then repeating the process until the desired
number of lines is reached. This means one doesn't have to read the whole file
and the picking process is much faster than the scan method. It might be
preferred for very large files.

Note that due to the nature of the algorithm, lines are weighted by the number
of characters. In other words, lines that have long lines immediately preceding
them will have a greater probability of being picked. Depending on your use case
or the line length variation of your file, this algorithm might or might not be
acceptable to you.


=item L<File::Random::Pick>

Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>

This module is an alternative to L<File::Random>. It offers a C<random_line()>
routine that avoids duplication.



( run in 0.268 second using v1.01-cache-2.11-cpan-65fba6d93b7 )