my $h; my $handle = tie $h, 'IPC::Shareable', { destroy => 'Yes' }; # start remote command for each host my $pm = new Parallel::ForkManager(scalar @hosts_to_run); $pm->run_on_finish( sub { my ($pid,$exit_value,$ident) = @_; print "finished run on $ident\n" if $verbose; } ); foreach my $host (@hosts_to_run) { my $pid = $pm->start($host) and next; my $result = #some calculations $handle->shlock(); $h->{$host}{output} = $result; $handle->shunlock(); $pm->finish(0); } $pm->wait_all_children; IPC::Shareable->clean_up_all;