in reply to Modify hash reference itself
But this will require you to only pass hash references, and work on the changed reference later. It will only change $myhsash, NOT %myhash.$myhash = \%myhash; mergetwohashes($myhash, \%b); sub mergetwohashes { #my($a)=$_[0]; my($b)=$_[1]; $_[0] = { %{$_[0]}, %{$b} }; }
Or you could do this:
But this way you only change the (complete) contents of the hash, the hash itself stays the same. But I'd guess this is just what you want...sub mergetwohashes { my($a)=$_[0]; my($b)=$_[1]; %{$a} = ( %{$a}, %{$b} ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Modify hash reference itself
by jweed (Chaplain) on Dec 02, 2003 at 00:38 UTC | |
|
Re: Re: Modify hash reference itself
by Anonymous Monk on Dec 02, 2003 at 00:41 UTC |