for my $k (sort keys %ManagerInCharge){ print "Month: $k\n"; my @keys = keys %{$ManagerInCharge{$k}}; print "Managers: ", join(",", @keys), "\n"; }