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 #### 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