Data::Dumper is a good example how to print a data structure. It is also not difficult to write a recursive sub that does a similar thing. See below. You could also add a callback function that searches for whatever. I made some assumptions about the data structure you are looking at but I think my example is relatively general.

use strict; use Data::Dumper; my %hash; $hash{Company_A}{ Identifier_1 } = ["a", "b"]; $hash{Company_A}{ Identifier_2 } = ["b", "g"]; + $hash{Company_A}{ Identifier_3 } = "c"; $hash{Company_B}{ Identifier_1 } = "a"; $hash{Company_B}{ Identifier_2 } = "g"; $hash{Company_B}{ Identifier_3 } = "x"; print Dumper(%hash); traverse( 0, \%hash ); sub traverse { my $level = shift; my $ref = shift; if( ref($ref) =~ /HASH/ ) { print "\n"; for my $key (keys %$ref) { print "\t" x $level, $key; traverse( $level+1, $$ref{$key} ); } } elsif( ref($ref) =~ /ARRAY/ ) { print "\n"; for (@$ref) { print "\t" x $level; traverse( $level+1, $_ ); } } else { print "\t" x $level, $ref, "\n"; } }

In reply to Re: Searching and printing complex data structures by hdb
in thread Searching and printing complex data structures by Anonymous Monk

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.