#! perl -slw use strict; use threads; use threads::shared; use Net::Telnet; my %data :shared; sub thread { my( $machine, $user, $pass, $cmd ) = @_; $t = new Net::Telnet ( Timeout => 10, Prompt => '>' ); $t->open( $machine ); $t->login( $user, $pass ); my @lines :shared = $t->cmd( $cmd ); $t->close; lock %data; $data{ $machine } = \@lines; return; } # AoA each sub array containing machineId, username, password and command to run my @credentials = ...; my @threads = map threads->create( \&thread, @$_ ), @credentials; $_->join for @threads; ## Do something useful with the data gathered in %data.