Hi,

I'm trying to read an HTML table from JBoss's Destination Manager, strip out only the table rows I'm interested in and then write it back out as an HTML table. What I've done so far (see Fig 1 below) is to grab every table off the page (although there is in fact only one) into $tables. What I'm not sure of is how to turn that into a hash that I can then write out with HTML::HashTable.

I printed the contents of $tables via Data::Dumper and got the structure you see in Fig 2. Out of curiosity, I pasted that into my code and assigned it to %table, but then the output of print tablify... was:

<table border=0>
<tr>
       <td>HASH(0x199ca080)</td>
       <td></td>
</tr>
</table>

Presumably because it couldn't read down into the data structure I gave it.

I'm at a bit of a loss as to how to convert one structure into the other as I'm finding the dereferencing syntax for anonymous data structures somewhat impenetrable. Can anyone help?

Regards,

Richard Cross.

-- Fig 1 - My code so far (I've cut out a whole load of extra CGI stuff that isn't relevant to my question) --
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard escapeHTML);
use HTML::HashTable;
use HTML::TableContentParser;

my $HTML = `./twiddle.sh invoke jboss.mq:service=DestinationManager listMessageCounter`;
my $parser = HTML::TableContentParser->new;
my $tables = $parser->parse($HTML);

#
# I need to get the first element of $tables and somehow turn it into a hash (%table) that I can use below
#

print tablify({
       BORDER      => 0,
       DATA        => \%table,
       SORTBY      => 'key',
       ORDER       => 'desc'}
   );


-- Fig 2 - what is returned from HTML::TableContentParser --$VAR1 = [
{
           'width' => '100%',
           'cellspacing' => '1',
           'cellpadding' => '1',
           'border' => '1',
           'headers' => [ { 'data' => 'Type' },
                          { 'data' => 'Name' },
                          { 'data' => 'Subscription' },
                          { 'data' => 'Durable' },
                          { 'data' => 'Count' },
                          { 'data' => 'CountDelta' },
                          { 'data' => 'Depth' },
                          { 'data' => 'DepthDelta' },
                          { 'data' => 'Last Add' }
                        ],
           'rows' => [ {},
{ 'cells' => [ { 'rowspan' => '1', 'data' => 'Queue' }, { 'rowspan' => '1', 'data' => 'A' },
                                      { 'data' => '-' },
                                      { 'data' => '-' },
                                      { 'data' => '0' },
                                      { 'data' => '-' },
                                      { 'data' => '0' },
                                      { 'data' => '-' },
                                      { 'data' => '-' }
                                    ],
                         'bgcolor' => '#F0F0F0'
                       },
{ 'cells' => [ { 'rowspan' => '1', 'data' => 'Queue' }, { 'rowspan' => '1', 'data' => 'B' },
                                      { 'data' => '-' },
                                      { 'data' => '-' },
                                      { 'data' => '0' },
                                      { 'data' => '-' },
                                      { 'data' => '0' },
                                      { 'data' => '-' },
                                      { 'data' => '-' }
                                    ],
                         'bgcolor' => '#FFFFFF'
                       },

                     ],
        }
];

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to