sub thread_worker { my $n = shift; # thread N my @args = shift; my %temp = (); .... while(1) { .... $totals{$n}->{STEPS} = $s; # record step $temp{$s}=$random; # add value to per-thread hash $totals{$n}->{HASH}= &share( \%temp ); # copy results to shared structure .... } }