my @db; $db[$monthNumber]->{ProductName}{RegionName} = $Quantity; # Loop through Month.. for (0..11){ #Cycle through Months, assuming zero-based next unless my %prod = %{$db[$_]}; # Any data there ? print "Some MONTH $_ header here\n"; foreach (sort keys %prod){ my %region = %{$prod{$_}}; # $region{RegionName} now has the qty to be printed # Hopefully, you get the idea now... } }