my %reasons; while (my($city, $code_info) = each %$switch_hash) { my ($code, $date_info) = %$code_info; while(my ($date, $reason) = each %$date_info) { next unless $reason =~ /^(\d+):(.*)/; $date_info->{$date} = $1; $reasons{"$city:$date"} = $2; } } #### my $switch_hash = { 'Washington:uslecwas5e1' => { '01-AUG-2002' => '' }, 'Charleston:uslecchst5e1' => { '01-AUG-2002' => '' }, 'Richmond:uslecric5e1' => { '01-AUG-2002' => '' }, # ... #### my $switch_hash = { 'Washington' => { CODE => 'uslecwas5e1', '01-AUG-2002' => '' }, # ... #### my %reasons; while (my($city, $info) = each %$switch_hash) { while(my ($date, $reason) = each %$info) { next unless $reason =~ /^(\d+):(.*)/ and $date ne 'CODE'; $info->{$date} = $1; $reasons{"$city:$date"} = $2; } }