smack has asked for the wisdom of the Perl Monks concerning the following question:
# 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]"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storing table data in a (simulated) multidimensional array
by davido (Cardinal) on Dec 08, 2004 at 16:18 UTC | |
|
Re: Storing table data in a (simulated) multidimensional array
by jZed (Prior) on Dec 08, 2004 at 17:31 UTC |