I remember something about not changing the keys in a
for my $key ( keys %hash ) { ...
for example
for my $key ( keys %hash
you cannot rename any key value instead you can delete and create a new one which is not lesser than renaming a key! :-)
for my $key ( keys %hash ) { delete $hash{$key}; $hash{$key} = "$key_x"; }