in reply to Updating a same hash using recurrsion ...

Untested, simplified code suggestion:
sub get_lower_level_ehms_count { my %design_hash = %{$_[0]}; my %ehm_count ; my $embedded = $design_hash{'EMBEDDED_HMS'} or return \%ehm_co +unt; for my $emb (@$embedded) { my $design_top = $emb->{'TOP'}; if($emb->{'EMBEDDED_HMS'}) { $lower_levels = get_lower_level_ehms_count($emb); $ehm_count{$_} += $lower_levels->{$_} for keys %$l +ower_levels; } $ehm_count{$design_top} += scalar @{$emb->{'INSTANCES'}}; } return \%ehm_count; }

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams