my %keys = qw( monster 0 hp 1 size 2 AC 3); my @data = ( [qw(troll 30 10 2)], [qw(dwarf 20 2 9 )], [qw(pixie 2 1 30 )]); foreach my $line (@data) { print "name @$line[$keys{'monster'}] \n"; print "\thas @$line[$keys{'hp'}] hit points\n"; }