%singleLevelHash = ( 'thirdLevelSampleKeyOne' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyTwo' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyThree' => 'thirdLevelSampleValue', ); #### #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %singleLevelHash = (); my %multiLevelHash = ( 'firstSampleKey' => 'SampleValue', 'secondSampleKey' => { 'secondLevelSampleKey' => { 'thirdLevelSampleKeyOne' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyTwo' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyThree' => 'thirdLevelSampleValue', } } ); print Dumper \%multiLevelHash; foreach my $firstSampleKey ( sort keys %multiLevelHash ) { print $firstSampleKey . "\n"; foreach my $secondLevelSampleKey ( sort keys $multiLevelHash{$firstSampleKey} ) { print $secondLevelSampleKey . "\n"; } } __DATA__ $VAR1 = { 'firstSampleKey' => 'SampleValue', 'secondSampleKey' => { 'secondLevelSampleKey' => { 'thirdLevelSampleKeyOne' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyThree' => 'thirdLevelSampleValue', 'thirdLevelSampleKeyTwo' => 'thirdLevelSampleValue' } } }; firstSampleKey Type of argument to keys on reference must be unblessed hashref or arrayref at hash.pl line 21.