Yes,its much more powerful, the way you said, but in my case it won't be 
necessary or important. 

Here I guess, I gave a wrong example where the data can be changed. 

Lets assume, the hash of hash being a record of something which has already 
happened and hence we know the final value, not something which is right now 
happening, i.e changeable. 

In my case, its like

$Position{$Scrip}{$Date}= #some value 

That is, my position in a previous date $Date, in the stock $scrip, was some 
integer. Thanks for the correction, regarding the brackets. I stand corrected 
and it seems I have made a lot of such mistakes apparent in the previous two 
three mails.

Soham




________________________________
From: Thomas Bätzler <t.baetz...@bringe.com>
To: beginners@perl.org
Cc: Soham Das <soham...@yahoo.co.in>
Sent: Tuesday, 29 September, 2009 3:46:28 PM
Subject: AW: Hash of Hashes

Soham Das <soham...@yahoo.co.in> 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



      Connect more, do more and share more with Yahoo! India Mail. Learn more. 
http://in.overview.mail.yahoo.com/

Reply via email to