in reply to Help with array ref in hashes

Your posted code fails compile with the error
Missing $ on loop variable
Please make sure that when you post code, it literally replicates your issue -- see How do I post a question effectively?.

If I run the code:

my %lengths = ( 1 => {x => 1, y => 2, z => [1,2,3], }, 2 => {x => 2, y => 3, z => [2,3,4], }, 3 => {x => 4, y => 5, z => [5,6,7], }, ); for my $coord (keys %lengths) { for (@{$lengths{$coord}{z}}) { print "$_\n"; } }
I get the output
1 2 3 5 6 7 2 3 4
which seems to be your spec. My best guess is that you've got a typo in the code you are actually running, so that you aren't accessing the array. Try checking Data::Dumper after your loop to see if you are getting bitten by autovivification.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.