$price_by_type_and_color{$car}{$color} = $amount; #### printf "%s\n",$_ for sort keys %price_by_type_and_color; Output: Bus Car Truck