foreach my $idx ( 0 .. $#names ) { $people{$names[$idx]} = { number => $idx, numbx2 => $idx * 2, }; }