$ perl -Mstrict -Mwarnings -E ' my %people; $people{ Fred }->{ age } = 37; $people{ Fred }->{ sex } = q{male}; $people{ Fred }->{ occ } = q{plumber}; $people{ Mary }->{ age } = 41; $people{ Mary }->{ sex } = q{female}; $people{ Mary }->{ occ } = q{barmaid}; my @order = qw{ age sex occ }; foreach my $person ( keys %people ) { say qq{$person:}; foreach my $attr ( @order ) { say qq{ $attr: $people{ $person }->{ $attr }}; } }' Mary: age: 41 sex: female occ: barmaid Fred: age: 37 sex: male occ: plumber $