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