in reply to Correct syntax to access an array slice within a hash within a hash
Hope this helps. Note the use of Data::Dumper - always use it when you are molding your data structures. It is a true life saver. ;)use strict; use Data::Dumper; my @shape; for (0..9) { unless ($_ % 2) { $shape[$_]->{shape} = 'rect' } else { $shape[$_]->{shape} = 'circle' } $shape[$_]->{coords} = [0,1,2,3,4,5,6,7,8,9]; } # what does it look like now? print Dumper \@shape; # and to get that slice: for (0..$#shape) { print "shape $_ is a ", $shape[$_]->{shape}, " (", join(',',@{$shape[$_]->{coords}}[0..3]), ")\n"; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|