Soham Das <[email protected]> asked:
> How can I create a Hash of Hashes from two lists. Is it possible?
>
> I want the effective functionality to be served like this
>
> $ChildHash["Joe"]["21A"]="Sally"
>
> i.e Joe at 21A has a child called Sally. List1 here will be the name of
> Parents, List2 here will contain the house number.
Please keep in mind: square brackets are for arrays/lists. Curly brackets are
for hashes.
In any case, wouldn't it be smarter to organize your data differently?
I.e.:
%parent = ( 'Joe' => { 'address' => '21A', children => ['Dick','Sally'] } );
To add another child to an existing parent you'd then say
push @{$parent{'Joe'}{'children'}}, 'Jane';
To add a new parent:
@{$parent{'Sven'}}{'address','children'} = ( '9b', ['Bjorn'] );
HTH,
Thomas