How can I combine two Perl hashes?
perl
Solution
I use
my $result = { %$defaults, %$user_defined };
Problem
I'm asking this question before I go down a long / verbose / incorrect way of doing this. I'm using Perl. I have two Hashes. One contains default values, one possibly user defined values which in some cases would override the default values. What is the easiest way to join these hashes together but there there is both a default and user defined value for the same key we choose the user value. ``` $defaults = { type => paper, number => 3 }; $user_defined = { number => 5 }; ``` The final conjoined output/hash required is ``` $result = { type => paper, number => 5, } ```