in reply to Concatenate anonymous hash ref

See Hash::Merge.

Also, depending on what values you want to survive, you can use the following approaches:

$x = { foo => "abc", from => 'x' }; $y = { bar => "def", baz => "ghi", from => 'y' }; my $merged_x = { %$y, %$x }; my $merged_y = { %$x, %$y };

If you want to modify $x in-place, you can also use a hash slice:

@{$x}{keys %$y} = values %$y; # Values in $y override values in $x