$myhash = \%myhash; mergetwohashes($myhash, \%b); sub mergetwohashes { #my($a)=$_[0]; my($b)=$_[1]; $_[0] = { %{$_[0]}, %{$b} }; }