Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found