Try iterating over %date_slots and printing the customer data || 'no data'; Example:
#!perl -w %HoH = ( cat => { 'FY2003-Q2' => { 'this is the customers data' => '1' }, 'FY2003-Q4' => { 'this is the customers data' => '1' }, 'FY2004-Q1' => { 'this is the customers data' => '1' }, 'FY2004-Q2' => { 'this is the customers data' => '1' }, }, dog => { 'FY2003-Q2' => { 'this is the customers data' => '1' }, 'FY2003-Q1' => { 'blah blah blah' => '1' }, }, catdog => { 'FY2004-Q1' => { 'blah blah blah' => '1' }, 'FY2004-Q2' => { 'blah blah blah' => '1' } } ); my %date_slots = ( 1 => 'FY2003-Q2', 2 => 'FY2003-Q3', 3 => 'FY2003-Q4', 4 => 'FY2004-Q1', 5 => 'FY2004-Q2', ); foreach $customer (keys %HoH) { print "$customer\n"; foreach $slot (sort keys %date_slots) { $date = $date_slots{$slot}; print "\t\t$date = "; ($key, $val) = each %{$HoH{$customer}{$date}}; print $key || "no data"; print "\n"; } # foreach $date (keys %{$HoH{$customer}} ) { # print "\t\t$date"; # foreach my $data (keys %{$cal{$customer}{$date}} ) { # print " = $data\n"; # } # } } __END__ # my results: cat FY2003-Q2 = this is the customers data FY2003-Q3 = no data FY2003-Q4 = this is the customers data FY2004-Q1 = this is the customers data FY2004-Q2 = this is the customers data dog FY2003-Q2 = this is the customers data FY2003-Q3 = no data FY2003-Q4 = no data FY2004-Q1 = no data FY2004-Q2 = no data catdog FY2003-Q2 = no data FY2003-Q3 = no data FY2003-Q4 = no data FY2004-Q1 = blah blah blah FY2004-Q2 = blah blah blah
Note: I had to fix up your %HoH and %date_slots hashes because they were missing ending quotes.
--
hiseldl
What time is it? It's Camel Time!
In reply to Re: Mix and Match Hashes
by hiseldl
in thread Mix and Match Hashes
by data67
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |