Your skill will accomplish what the force of many cannot |
|
PerlMonks |
RFC How to retrieve a hash from a hash of hashesby bdalzell (Sexton) |
on Jan 12, 2012 at 00:25 UTC ( [id://947461]=perlmeditation: print w/replies, xml ) | Need Help?? |
As a relatively new user of Perl's hash of hashes I still find some things hard to figure out. I have a database I am doing in perl where it is difficult to predict all the variables that might apply to a individual kind of data field and I have recently discovered that a technique used in library book cataloging where a kind of datafield may have several sub data fields can be implemented using hash of hashes and hash of arrays, etc. For example and individual's record might have an unpredictable number of awards earned. So the awards field can be a hash with award type for the key and award date for the value. So then I came to a point where I wanted to extract an individual's record (which is itself a hash) from the main database hash of records and assign it to a hash for sending to a subroutine for processing . Lots of searching with google failed to give me a result on "extract hash from hash of hashes and assign it to its own hash" or variations on this theme. So I finally found the article at perldoc on hashes and hashes of hashes and used it to figure out how to retrieve an individual record as a hash. But I would like to post the solution so other people might be able to find out how it is done directly: Original code inspiring this: perldsc
Back to
Meditations
|
|