Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

A hash of hashes is a two-dimensional structure that consists of a hash whose elements are references to other hashes.

- Static initialization

We use anonymous hashes to define the subhashes that are the elements of the hash:

Example:

%hash_of_hasess =  ( 'first' =>  {
                                    'one'   => '1', 
                                    'two'   => '2', 
                                    'three' => '3',
                                 },
                     'second' => {
                                    'four'  => '4',
                                    'five'  => '5',
                                 },
                   );

To access an individual value:

$value = $hash_of_hashes{'second'}{'four'};