foreach my $img ( keys %images ) { foreach my $typ ( keys %{$images{$img}} ) { ... # next layer -- content of $images{$img}{$typ} -- depends on value of $typ: ... # 'frac' has AoAoH ... # others have just a hash