print Dumper(\%categories); foreach $top ( sort keys %categories){ if($top =~ /^\s*$/){$top="";} print "$top\n"; foreach $second ( sort keys %{$categories{$top}}){ if($second =~ /^\s*$/){$second="";} print "...$second\n"; foreach $third (sort keys %{$categories{$top}{$second}}){ if($third =~ /^\s*$/){$third="";} print "......$third\n"; } } }