foreach my $key (keys(%bar)){ $foo{$key} = $bar{$key}; }