in reply to Um... WTF? Multi-dimensional hashes

I've never seen any particular documentation, but picked up in an example when looking for a hash of hashes. Hashes of arrays are useful for columnar data, but hashes of hashes allow you to keep a well ordered structure of data and pass it around like a football in your code if needed. As an example, say you want a hash of contacts data. Calling if exists on $contacts{$last}{$first} will tell you if you have that person in the contacts hash, so you can then look for other pertinent details. With the hash of hashes you have a hash for each person like $contacts{$last}{$first}{HomePhone}=
$contacts{$last}{$first}{WorkPhone}=
$contacts{$last}{$first}{HomeEmail}=
$contacts{$last}{$first}{WorkEmail}=
or any of the several ways to assign data to a hash value Accessing and assigning values can be a bit of a mind warp, but once you understand it, it is very useful and compact. see http://docstore.mik.ua/orelly/perl/prog3/ch09_04.htm for a bit more. I've been using such since 5.8 but am not sure how long it's been available.
  • Comment on Re: Um... WTF? Multi-dimensional hashes

Replies are listed 'Best First'.
Re^2: Um... WTF? Multi-dimensional hashes
by Your Mother (Archbishop) on Jun 22, 2009 at 03:48 UTC

    Well, that actually nothing to do with the question. And it's not good to link to pirated copies of books. :(