#!/usr/bin/env perl use strict; use warnings; use Algorithm::Combinatorics qw(combinations); use MCE::Loop; MCE::Loop->init( max_workers => 12, # what ever you have... chunk_size => 'auto' ); my $length = 10; my $ones = 2; mce_loop { my ( $mce, $chunk_ref, $chunk_id ) = @_; for ( @{$chunk_ref} ) { something($_); } } combinations([0..$length-1], $ones); sub something { my $chunk_ref = shift; ...; }