in reply to Modify hash reference itself

The assignment operator '=' won't do what you want. It gives a new value to the scalar $a; it can't affect what %myhash is. If %myhash is a global, you can get the effect you want by passing the glob *myhash instead of \%myhash 1, because there you have an opportunity to assign to the thing that contains %myhash; otherwise there is no way to do exactly what you want2.

It sounds like it would be better for you to not have a hash %myhash but a hashref $myhash instead. Then you can pass it to mergetwohashes and modify $_[0] there to change what hash it points to.

1 I think that will even work with your sub as is, given the magic nature of assignment to glob and dereferencing a glob.

2 Actually not quite true, as you can tie %{$_[0]} in your sub and make %myhash appear to reference a different hash.