use threads; sub doit { ... } my @threads = map{ threads->new( \&doit, $args[ $_ ] ) } 0 .. $n - 1; $_->join for @threads;