Please make sure that when you post code, it literally replicates your issue -- see How do I post a question effectively?.Missing $ on loop variable
If I run the code:
I get the outputmy %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"; } }
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.1 2 3 5 6 7 2 3 4
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
In reply to Re: Help with array ref in hashes
by kennethk
in thread Help with array ref in hashes
by diyaz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |