%hash = ( for($b=0;$b<$cnt;$b++){$a=$b+1; #$cnt being the number of keys in the hash $new"."$a="new_input_from_form"."$a";#. form is in a .pl file if($new"."$a ne ""){$new_key_and_value="'$a' => '$new"."$a',";} #use value from the form in the hash elsif($new"."$a eq ""){$new_key_and_value="'$a' => '$hash{'$a'}',";} #use the old value from the exi +sting hash $new_key_and_value }#close the for loop ); #close the hash