use threads; use threads::shared; my @threads; for(my $index = 0; $index < scalar(@input_files); $index++) { push(@threads, threads->new(\&doProcessing, $input,$output)); #$input and $output are the contents of input and output files } my @ReturnData; foreach my $thread (@threads) { push(@ReturnData,$thread->join()); }