$hashone = &shared({}); $arrayone = &shared([]); $hashone->{"arraykey"} = $arrayone; for loop{ #some other stuff $hashtwo = &shared({}); push($arrayone, $hashtwo); $arraytwo = &shared([]); $hashtwo->{$filename} = $arraytwo; #add some other values to hashtwo if ($#threads >=9) { $thread = shift(@threads); $thread->join(); undef $thread; } push (@threads, threads->create(\&threadfunction, $filename, $arraytwo); } # clean up all the other threads, finish as I would without threading sub threadfunction { ($filename, $arraytwo) = @_; open(PIPE, "outputprogram $filename |"); while () { #add various $hasthree = &shared({}) to $arraytwo #add various values to $hashthree's } close PIPE; }