This is far outside my level of comfort, and I'm facing a very interesting sitaution. Essentially, I'm dealing with a massive hash. I have access to the hash reference, and I want to traverse the hash and take out the names of the other hashes and their keys. I want to ignore values. Using Data::Dumper is unreadable due to size.

Let me show an example. Note that this is all inside the main hash reference

'flags' => { 'example' => 0, 'font_attributes' => { 'size' => -1, 'colors' => '' }, 'Redacted' => 0, 'Redacted' => [], 'font_changes' => { 'size' => -1, 'colors' => -1 }, 'Redacted' => 0, 'Redacted2' => -1, 'Redacted3' => -1, 'Redacted4' => 0 }, 'Domains' => {}, 'removed_results' => [], 'Words' => {}, 'other_results' => {}, 'recipient_list' => [ 'test@test.com' ], 'Clean' => { 'extra' => {} }, 'result' => 'pass', 'Lists' => { 'Body' => { 'RedactedWordList' => { 'words' => { 'word1' => '5', 'word2' => '1', }, 'words_found' => [], 'weight' => 0 } } }

As you can tell, it just keeps going and going and going and going. I want to be able to print everything except the values. So $startingHash with hashes within it, and those hashes having hashes within them. I want to print the name of every "hash name" and every "key" in a readable format. I can't seem to wrap my brain around how I could do that. I'm tasked with documenting everything available within this mega hash, but I don't need the actual value obviously


In reply to Traversing a hash of hashes of hashes by kcorj2244

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.