Thanks again but I couldn't get Hobo to do it. I'm just a humble pilgrim in the
Holy Land of MCE. Thanks to the seemingly infinite amount of elaborate example code I have tried many things. As you will see below my
cargo cult strategy simply replaces numbers with letters to see if it works.
MCE::Candy caught my eye for preserving output order because my old method did that, even thought it's not necessary. I found the magic in MCE::Candy::out_iter_array:
#!/usr/bin/perl
use strict;
use warnings;
use MCE;
use MCE::Candy;
my $volume = 26*26;
my $max_workers = 4;
my $chunk_size = int $volume / $max_workers;
my @results;
my $mce = MCE->new(
max_workers => $max_workers,
chunk_size => $chunk_size,
gather => MCE::Candy::out_iter_array(\@results),
user_func => sub {
my ($mce, $chunk_ref, $chunk_id) = @_;
my @output;
foreach my $item (@{ $chunk_ref }) {
push @output, $item++;
}
$mce->gather($chunk_id, @output);
}
);
$mce->process([ 'aa' .. 'zz' ]);
print "$_, " for @results;
print scalar @results, "\n";
https://github.com/marioroy/mce-perl/blob/master/README.md
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.