I have a perl HOH (hash of hash) wherein i have serial numbers 1,2,3.... so on and directory paths with associated counter values. Could anyone please suggest a way in which i can merge the duplicate internal paths (e.g, /usr/lib , /bin/ ) to a form a new hash with addition of the values?
Sample HOH:
$VAR1 = {
'1' => {
'/usr/lib' => 18
},
'3' => {
'/bin/' => '3'
},
'4' => {
'/usr/lib' => 12
},
'2' => {
'/bin/' => '6'
},
'5' => {
'/dev/' => '2'
},
'6' => {
'/tmp/' => '8'
}
};
Final output requirement i am looking for is a simple hash with combined values. No need of serial numbers:
$VAR1 = {
'/usr/lib' => '30',
'/bin/' => '9',
'/dev/' => '2',
'/tmp/' => '8'
};