Hello all,
I'm trying to compare hash structures and return the unique values of each hash.
Now basically, when they're compared, I want a hash structure returned showing me that hash2 has 1 additional 'add' value (in this it being val7). Comparing the two's equality is relatively easy; finding the diff between one or the other is what I'm having trouble with.
I've read that I can use grep do to this, but from my limited experience using Perl's grep, I thought it only worked on arrays. Any help would be much appreciated.
I'm trying to compare hash structures and return the unique values of each hash.
Code:
my $hash1 = { 'add' => { 'val1' => 1,
'val2' => 1,
'val3' => 1 },
'remove' => { 'val4' => 0,
'val5' => 0,
'val6' => 0 }};
my $hash2 = { 'add' => { 'val1' => 1,
'val2' => 1,
'val3' => 1,
'val7' => 1},
'remove' => { 'val4' => 0,
'val5' => 0,
'val6' => 0 }};
Now basically, when they're compared, I want a hash structure returned showing me that hash2 has 1 additional 'add' value (in this it being val7). Comparing the two's equality is relatively easy; finding the diff between one or the other is what I'm having trouble with.
I've read that I can use grep do to this, but from my limited experience using Perl's grep, I thought it only worked on arrays. Any help would be much appreciated.