in reply to Modify hash reference itself
And the output is as expected -use strict; use Data::Dumper; my %hash1 = qw/ A 1 B 2 /; my %hash2 = qw/ C 3 D 4 /; mergetwohashes(\%hash1, \%hash2); print Dumper(\%hash1); sub mergetwohashes { my ($a, $b) = @_; $a->{$_} = $b->{$_} foreach keys %$b; }
$VAR1 = { 'A' => '1', 'B' => '2', 'C' => '3', 'D' => '4' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Modify hash reference itself
by Anonymous Monk on Dec 02, 2003 at 00:55 UTC | |
by Roger (Parson) on Dec 02, 2003 at 01:07 UTC |