#!/usr/bin/perl my %HoH= ( 'test1' => { 'keyname'=>'test1', 'price' => '10.00', 'desc' => 'the 1st test'}, 'test2' => { 'keyname'=>'test2', 'price' => '12.00', 'desc' => 'the 2nd test'}, 'test3' => { 'keyname'=>'test3', 'price' => '13.00', 'desc' => 'the 3rd test'}, 'test4' => { 'keyname'=>'test4', 'price' => '14.00', 'desc' => 'the 4th test'} ); my %child_hash = &new_hash; my $key = $child_hash{'keyname'}; ## 2 ways to add a newly made hash to the hash of hashes # directly # $HoH{"$key"} = ({%child_hash}); # or by reference $HoH{"$key"} = \%child_hash; my @keys = keys %file_tests; @keys = sort @keys; foreach my $key(@keys){ print "$key price is: $HoH{$key}{'price'}\n"; } sub new_hash { my %hash = ( 'keyname' => 'test5', 'price' => "20.00", 'desc' => "the 5th test"); return %hash; }