in reply to Re: hash of arrays to array of arrays
in thread hash of arrays to array of arrays

Ok, I think I see what you're trying to do.

  1. walk through threads
  2. each key in threads points to an array ref
  3. store each arrayref into an array

modifying your code without munging it too much, I change to storing the array ref in $tlist[$tnum]; And then when we access from $tlist, we dereference into the array.

The syntax you had @tlist[$i] was actually doing an array slice.

print "\n\nThe Hash Table\n\n"; foreach $thread (keys %threads) { print "$thread: @{$threads{$thread}}\n"; } #this prints out lines like: #keyA: 2 6 8 #keyB: 3 5 10 14 18 #etc. # Convert hash table into arrays for Threads, with common index $tnum $tnum=0; foreach $thread (keys %threads) { $tsub[$tnum] = $thread; $tlist[$tnum] = $threads{$thread}; #store the array reference. $tsize[$tnum] = @{ $tlist[$tnum] }; $tnum++; } print "\n\nThe Thread Arrays\n\n"; for ($i=0;$i<$tnum ;$i++) { print "\n$tsub[$i], size=$tsize[$i], @{$tlist[$i]"; }