I'm trying to merge two blessed hashes in Perl.
I'm running the following code:
#!usr/bin/perl
use strict;
use warnings;
use Hash::Merge;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
my $hash1 = bless( {
'CalcPorts' => {
'helper_1' => {
'Scope' => [
''
],
},
'helper_2' => {
'Scope' => [
''
],
},
},
}, 'IB' );
my $hash2 = bless( {
'CalcPorts' => {
'helper_2' => {
'Scope' => [
'd'
],
},
},
}, 'IB' );
my $merger = Hash::Merge->new('LEFT_PRECEDENT');
my $hash3 = $merger->merge($hash2, $hash1);
print Dumper($hash3);
The output is this:
$VAR1 = bless( {
'CalcPorts' => {
'helper_2' => {
'Scope' => [
'd'
]
}
}
}, 'IB' );
Even though I would have expected the "helper_1" to be there... Any ideas what am I doing wrong? Thanks for your help :)