http://www.perlmonks.org?node_id=11125773

kalee has asked for the wisdom of the Perl Monks concerning the following question:

I've create a simple hash reference with the following data:

my $weapons_ref = { dagger => { cost => 8, damage => 4, armor => 0 }, shortsword => { cost => 10, damage => 5, armor => 0 }, warhammer => { cost => 25, damage => 6, armor => 0 }, longsword => { cost => 40, damage => 7, armor => 0 }, greataxe => { cost => 74, damage => 8, armor => 0 }, };

I want to reference both the data in the first list of keys, then the data is the subsets. Much like I would in a map with (javascript). Though, I would think this would be just as easy in Perl, I just haven't figured it out and need some help.

I need to look though the weapons "list". I would also like to sum by cost, damage and armor in calculations.

I was hoping there would be an easy was to sum the weapons cost for example. I was thinking I could do this with a postfix operation, but my general confusion with a hash of a hashes keeps getting in the way. Any wisdom would be appreciated!



If you have general information for learning how to manipulate array of hashes and hash of hashes in general, that would be appreciated as well. I really would like to really understand this better!

Thank you

KALee