hello Monks,

maybe I can give my answer ?!? fantastic !! I was warking on dumping HoH on the screen for a better overview and I wrote this:
my %h2=( 'AAA' => 'aaa', 'BBB' => 'bbb', 'CCC' => {'A1' => a1, 'B1' => 'b1', 'C1' => {'A2' => a2,'B2' => 'b2','C2' => 'c2END'}}, 'DDD' => 'ddd', ); my $ref2 = \%h2; &ddump($ref2); sub ddump { my $ref = shift; my $deep = shift||1; foreach my $k (sort keys %{$ref}) { if (ref( ${$ref}{$k})) {print "\t" x $deep."$k =>\n"; &ddump (${$ref}{$k}, ($deep+1)) } else {print "\t" x ($deep)."$k => ${$ref}{$k}\n";} $deep-1; } }
Then I found a column by Merlyn, only 8 year later, that suggested me a new rebus to solve: how about to dump via CGI.pm table ?? or to be precise Hohoh->TableOfTableOfTable here the code:
use warnings; use CGI qw /:all -nph/; #on Win32 $|++; $POST_MAX=100; $DISABLE_UPLOAD=1; print header(); print start_html(); my %HoHoH = ();#feed your hoh here my $ref2 = \%HoHoH ; print &table_center(&complextable($ref2)); print end_html; sub td_center{{-align=>center} td([@_]); }#separated for customization sub tr_center {{-align=>center}Tr([@_]); } sub table_center { table({-title=>'oOOOo', -bgcolor=>"#000000", -border=>1, -bordercolor=>"red", -cellspacing=>"0", -width=>"80%", -cellpadding=>"0"}, @_); } sub complextable { my $ref = shift; my @righe; foreach my $k (sort keys %{$ref}) { if (ref( $$ref{$k} )) { push @righe, (&tr_center (&td_center ($k,(&table_center (&complextable($$ref{$k})) ) ) ) ) ; } else { push @righe, (&tr_center(&td_center($k, $$ref{$k} ))); } } return @righe; }
Hope this help. Hope some golf master to squize my homegrown code.

cheers from sunny Roma
Lor*

Originally posted as a Categorized Answer.


In reply to Re: How can I visualize my complex data structure? by Discipulus
in thread How can I visualize my complex data structure? by planetscape

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.