Not forget the immediate import statement if calling require, necessary for the MCE Models.

use strict; use warnings; use feature 'say'; require MCE::Map; import MCE::Map; MCE::Map-> init( chunk_size => 1, max_workers => 4, user_begin => sub { print "## ", MCE-> wid, " started\n"; }, user_end => sub { print "## ", MCE-> wid, " completed\n"; }, ); my @a = MCE::Map-> run( sub { $_ }, [ 0 .. 9 ]); MCE::Map-> finish; print "\n", "@a", "\n"; say $MCE::VERSION; __END__ ## 1 started ## 3 started ## 2 started ## 4 started ## 2 completed ## 4 completed ## 1 completed ## 3 completed 0 1 2 3 4 5 6 7 8 9 1.901

Here is the MCE variant. Ordered output is possible using MCE::Candy.
Note $chunk_id as the first argument to gather. MCE->chunk_id works too.

use strict; use warnings; use feature 'say'; require MCE; require MCE::Candy; my @in = ( 0 .. 9 ); my @out; my $mce = MCE-> new( chunk_size => 1, max_workers => 4, user_begin => sub { print "## ", MCE-> wid, " started\n"; }, user_end => sub { print "## ", MCE-> wid, " completed\n"; }, user_func => sub { my ( $mce, $chunk_ref, $chunk_id ) = @_; MCE-> gather( $chunk_id, $_ ) }, input_data => \@in, gather => MCE::Candy::out_iter_array(\@out), ); $mce-> run; $mce-> shutdown; say "@out"; __END__ ## 1 started ## 2 started ## 4 started ## 3 started ## 3 completed ## 4 completed ## 2 completed ## 1 completed 0 1 2 3 4 5 6 7 8 9

In reply to Re: Can't require MCE::Map (Strawberry)? by marioroy
in thread Can't require MCE::Map (Strawberry)? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.