Thanks for the reply. but the code u gave prints the contents as below. VAR1 = { '' => { 'last_used' => '2007/12/20', 'user_name' => 'xyz', 'host_name' => 'nett1' } }; But I need to print the contents as the below code does. foreach (sort keys %hoh){ print "$_ "; my $tmp_hash = $hoh{$_}; foreach (sort keys %$tmp_hash){ print $$tmp_hash{$_}; print " "; } print "\n"; }