List::MapBruteBatch - Do a brute-force batched map() though a list with a callback
map()
map_brute_batch($cb, \@list); my @ret = map_brute_batch($cb, \@list, \$cb_success, \$cb_failure);
Firstly. Why would you use this?
You have some N number of items you want to process. You have some function that can take those N, and it's much cheaper to do them in one big batch than one at a time.
N
However, any one of the N items can fail, causing the entire batch of N to fail with it. When that happens you either don't know which one failed the batch, or finding out would be tedious.
This module provides a map()-like function to solve that problem. It'll attempt to process a \@list you provide with a $cb function that you provide.
\@list
$cb
If your $cb doesn't return true we bisect the \@list and call your $cb on each half of the bisected list, and if those fail we repeat this process until we're processing one item, which may also fail.
You can optionally provide $cb_success or $cb_failure callbacks, those'll be called in map()-like fashion on items that fail or succeed, respectively. You can use this to make the function return a list of items showing which items ended up failing or succeeding.
$cb_success
$cb_failure
Ævar Arnfjörð Bjarmason <avar@cpan.org>
This software is copyright (c) 2013-2016 by Ævar Arnfjörð Bjarmason <avar@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 List::MapBruteBatch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm List::MapBruteBatch
CPAN shell
perl -MCPAN -e shell install List::MapBruteBatch
For more information on module installation, please visit the detailed CPAN module installation guide.