use strict; use warnings; use feature 'say'; use Data::Dumper; ++$Data::Dumper::Sortkeys; use MCE::Loop; use MCE::Candy; my $aref = []; MCE::Loop::init( max_workers => 4, chunk_size => 1, gather => MCE::Candy::out_iter_array( $aref ), ); for ( 0, 1 ) { say "Test $_"; mce_loop { my ( $mce, $chunk_ref, $chunk_id ) = @_; warn "chunk_ref " . Dumper $chunk_ref; my ($chunk) = @{ $chunk_ref }; warn "chunk " . Dumper $chunk; MCE->gather( $chunk_id, $chunk->{'foo'} ); } @{ get_data( $_ ) }; say "$_ : " . Dumper $aref; $aref = []; } sub get_data { my $which = shift; if ( $which == 1 ) { return [ { foo => 'bar', baz => 'qux' } ]; } else { return [ { foo => 'bar', baz => 'qux' }, { foo => 'qux', baz => 'bar' }, ]; } } __END__