in reply to Re: How to loop through hash of hashes and add the values based on condition?
in thread How to loop through hash of hashes and add the values based on condition?
Attached the code which've tried ...
for $name ( sort keys %{$VAR1} ) { for $calen ( sort keys %{ $VAR1{$name} } ) { for $value ( sort keys %{ $VAR1{$name}{$calen} } ) { if ( $VAR1{$name} ne ‘Sum’ ) { if ( ($VAR1{$name}{$calen} eq ‘days’) || ($VAR1{$name} +{$calen} eq ‘weeks’) ){ $day_week_total += $VAR1{$name}{$calen}{$value} if +($VAR1{$name}{$calen}{$value}); } elsif ( ($VAR1{$name}{$calen} eq ‘months’) ){ $month_total += $VAR1{$name}{$calen}{$value} if($V +AR1{$name}{$calen}{$value}); } } } } print “day_tot: $day_week_total — mon_tot: $month_total“;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to loop through hash of hashes and add the values based on condition?
by pryrt (Abbot) on Jan 06, 2020 at 20:02 UTC | |
by Sami_R (Sexton) on Jan 08, 2020 at 19:39 UTC | |
|
Re^3: How to loop through hash of hashes and add the values based on condition?
by BillKSmith (Monsignor) on Jan 06, 2020 at 21:29 UTC | |
by Sami_R (Sexton) on Jan 08, 2020 at 19:42 UTC |