I have a hash of hashes, that is, hash and hash references in my data structure. Can I iterate through the deepest hash when I only have the main hash name and no key of the deepest hash?
my %gates_info=(
'order' => {
'nand' => {
'nand2_1' =>2,
'nand2_5' =>-1,
'nand2_4' =>2,
'nand2_6' =>-1,
'nand2_2' =>2,
'nand2_3' =>3
},
'and' => {
'and2'=>1,
'and3'=>2,
},
}
);
sub max_gate_order {
print values (%{$gates_info{'order'}});
my @arr = (sort {$a <=> $b} values %{$gates_info{'order'}});
return $arr[-1];
}
I want to iterate over the whole hash when I have just its name %gates_info and no keys such as "nand" or "and". What I am trying to achieve is to get the highest numeric value in each of the gates by sorting. Such as 3 in nand case and 2 in and case. Sub max_gate_order is used for sorting and returning highest value. Thanks