my $pool = Thread::Pool->new( {workers => 5, do => \&telnet2Cli} ); my $count = 0; foreach $value (@values) { $thr[$count] = $pool->job($threadUse, $value, "show version"); $count += 1; } my $index; my @versionOutput; for ($index=0; $index < $count; $index++) { $versionOutput[$index] = $pool->result( $thr[$index] ); }