Greetings monks. Although the problem is with a much larger hashref(media library information from my VLC player), I made this code for testing purposes but shares the same goal as my other code.
use strict; use warnings; my $hashref = { normal_enemies => { cloud_guy => { attacktype => 'thunder', power => 4, hp => 5, }, rain_man => { attacktype => 'water', power => 3, hp => 7, }, flame_kid => { attacktype => 'fire', power => 6, hp => 4, }, }, boss_enemies => { large_shark => { attacktype => 'water'. power => 9, hp => 13, special => 'none', }, wingding_monster => { attacktype => 'font'. power => 24, hp => 23, special => 'encrypt', }, green_dragon => { attacktype => 'fire'. power => 8, hp => 58, special => 'fire breath', }, }, items => { weapons => { sword_chucks => { power => 28, accuracy => 6, recommended_class => 'Crazy Fighter', }, cane => { power => 7, accuracy => 3, recommended_class => 'The Mage That Just Uses Magic. Y +ou know, if he ever needs to use this thing you\'re screwed anyway, r +ight?', }, katana => { power => 'over nine-thousand', accuracy => 8, recommended_class => 'Ninja Assassin', }, }, armor => { helm => { body_part => 'head', defense => 2.5, }, guantlets => { body_part => 'hands', defense => 1, }, necklace => { body_part => 'neck', defense => .1337, }, }, }, }; my %hash = %$hashref; print "Normal(Should fail with 'HASH(0xhex)' - $hashref\n"; print "Dereferenced - \n"; foreach (keys %hash) { print "$_ - $hash{$_}\n"; }
And the result is
Normal(Should fail with 'HASH(0xhex)' - HASH(0x99aae4) Dereferenced - normal_enemies - HASH(0x98a814) boss_enemies - HASH(0x99adc4) items - HASH(0x99ab24)
Now, what I want to do is take %hash deeper into the hashref. For example, how would I get a list of normal_enemies or the information from sword_chucks(this should come out as 'power - 28' instead of 'power - HASH(junk)') ? Thanks in advanced.

In reply to getting keys of multi-level hashrefs by mask_man

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.