foreach $key1 (keys %hshFoo) { foreach $key2 (keys %{$hshFoo{$key1}}) { print "$key1/$key2 => $hshFoo{$key1}{$key2}\n"; } } ... Output: 2823/1 => 2823_1.xml 2823/0 => 2823_0.xml 2823/3 => 2823_3.xml 2823/2 => 2823_2.xml ... I expected: 2823/0 => 2823_0.xml 2823/1 => 2823_1.xml 2823/2 => 2823_2.xml 2823/3 => 2823_3.xml