my @hashNames = qw(testA testB testC); my $i = 0; foreach (@hashNames) { %{$_}{'key'} = $i; } #### %testA = ( key => '0' );