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"; }