Greetings Fellow Monks:

I have found my self in need of organizing data from tables (Extracted with HTML::TableExtract). Right now I am storing the data in simulated multidimensional arrays. The code I have written seems to work, however, I don't think it is very efficient or proper. It seems there has to be a better way than what I am doing. Any suggestions or comments would be appreciated. Please let me know if I have not demonstrated well what I am trying to accomplish. Here is the code:

# Pull the tables out of the Web page # The output will be an array, with each component of it # array containing an entire row of the table, with each colomn # sepperated by a comma. my @tablerows = &FilterData(2, 0); my @aptable; # Now to split each element of the original array, and store # each column into the designated array for that column. # Initialize the column arrays my @tablecolumn0; my @tablecolumn1; my @tablecolumn2; my @tablecolumn3; my @tablecolumn4; my @tablecolumn5; # Spit each element of the original array, and push each part # into the appropriate column. foreach my $tablerow (@tablerows) { my @splitrow = split(/\,/, $tablerow); push (@tablecolumn0, @splitrow[0]); push (@tablecolumn1, @splitrow[1]); push (@tablecolumn2, @splitrow[2]); push (@tablecolumn3, @splitrow[3]); push (@tablecolumn4, @splitrow[4]); push (@tablecolumn5, @splitrow[5]); print "\n$tablerow"; } # Create references to the arrays thant contain table columns. # Store those references in an array to simulate # a multidiminsional array. my $column0 = \@tablecolumn0; push (@aptable, $column0); my $column1 = \@tablecolumn1; push (@aptable, $column1); my $column2 = \@tablecolumn2; push (@aptable, $column2); my $column3 = \@tablecolumn3; push (@aptable, $column3); my $column4 = \@tablecolumn4; push (@aptable, $column4); my $column5 = \@tablecolumn5; push (@aptable, $column5); # print two cells to see if it worked, which it does =) print "\n@aptable[1]->[1] is: @aptable[5]->[1]"; }

In reply to Storing table data in a (simulated) multidimensional array by smack

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.