my %hash; foreach (@list) { my $foo = 'longstring'.$_.'more'; $hash{$_} = { key1 => $foo, key2 => alter($foo), }; }