For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2005 > Hash of Lists









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Hash of Lists
Andrew Black

2005-06-06, 8:55 am

I am trying to set up a Hash of Lists and am following the example
http://www.perl.com/doc/manual/html...HASHES_OF_LISTS

Specifically
# append new members to an existing family
push @{ $HoL{"flintstones"} }, "wilma", "betty";

I don't understand why the construct @{ xxxxx } is written that way.
Can someone explain what it is trying to do and why it is written that way.

Andrew
Wijaya Edward

2005-06-06, 8:55 am



> Specifically
> # append new members to an existing family
> push @{ $HoL{"flintstones"} }, "wilma", "betty";
>
> I don't understand why the construct @{ xxxxx } is written that way.


Step by step, what it does is:
1. Dereference the List in the Hash with key "flinstones" ---> @{$array_ref} is dereferncing an array $array_ref
2. Thus you have an array of that hash (i.e. flinstones as key).
3. Finally you push "wilma" and "betty" into that array



Hope it's clear.

---
Regards,
Edward WIJAYA
SINGAPORE

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com