SPUG: Slice of HashOfHash

Eric.D.Peterson at alltel.com Eric.D.Peterson at alltel.com
Wed Nov 15 16:11:20 PST 2006


Given a Hash of a Hash is it possible to make a slice (I presume this
will be another hash) of a subset of the HoH based upon a value, not the
key?  For example:

my %HoH = (
    flintstones => 
    {
        husband   => "fred",
        pal       => "barney",
    },
    jetsons => 
    {
        husband   => "george",
        wife      => "jane",
        "his boy" => "elroy",  # Key quotes needed.
    },
    jones => 
    {
        husband   => "fred",
        wife       => "linda",
    },
    simpsons => 
    {
        husband   => "homer",
        wife      => "marge",
        kid       => "bart",
    }
);


How can I make a new hash  or loop through this HoH where husband =
"fred"?  

I've been reading up on slices and printing hashes, but I can't seem to
find an example or description on playing with HoH subsets.  I've tried
looping through the full HoH and adding those desired elements to a new
HoH but that seems awkward and not quite right & cumbersome.  So I
thought I'd ask ya'll for some help.


Cheers
Eric




******************************************************************************************
The information contained in this message, including attachments, may contain 
privileged or confidential information that is intended to be delivered only to the 
person identified above. If you are not the intended recipient, or the person 
responsible for delivering this message to the intended recipient, Alltel requests 
that you immediately notify the sender and asks that you do not read the message or its 
attachments, and that you delete them without copying or sending them to anyone else. 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/spug-list/attachments/20061115/61b98bdc/attachment.html 


More information about the spug-list mailing list