in reply to Best Multidimensional Hash Practices?
One useful practice for multidimensional hashes is not to use them indiscriminately. There's a tendency to make enormous, monolithic hashes that some people (myself included) sometimes exhibit, something like:
$user_data{$username}={"date of birth"=>$dob, "ID number"=>$idnum, "mailing address"=>[$street, $citystatezip, ], };
when it might (and probably would) be better to do something like:
$user_dob{$username}=$dob; $user_idnum{$username}=$idnum; $user_mailaddress{$username}=[...];
The obvious symptom of this, when I make this mistake, is a large number of constant strings for subkeys in a hash where the top level keys are of interest. It's just as easy to tie multiple hashes with nice meaningful names together by their keys as it is to keep it all in one hash where the meaning is split between the hash name and second/third level keys, and it's much easier to handle.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best Multidimensional Hash Practices?
by GrandFather (Saint) on Oct 12, 2009 at 21:36 UTC |