Hi,
related to a previous post - I have a bit of a cgi program that searches through an an array of arrays to return certain arrays depending on user input, these arrays then need to be displayed in a table in the browser. the code at the moment is as follows:
basically @array contains some elements that match the first element in the arrays in the AoA, when a match is made the array is stored in @matching_arrays. the output at the moment looks like this (e.g. if @array = ("val1", "val2", "val3"):
the problem i'm having is displaying the results in a table. i am using cgi.pm the object-oriented way, so the above result should be displayed as a table with 4 columns and 3 rows, and one "element" in each cell.... any hits would be great as i'm pretty stuck
related to a previous post - I have a bit of a cgi program that searches through an an array of arrays to return certain arrays depending on user input, these arrays then need to be displayed in a table in the browser. the code at the moment is as follows:
Code:
# Create an empty array
my @matching_arrays;
# for each result in @array
foreach my $result (@array) {
# Append to @matching_arrays all elements of AoA matching $result
push @matching_arrays, grep { ${$_}[0] =~ /$result/ } @AoA;
}
foreach (@matching_arrays) {
print $query -> p("\"" . join("\", \"", @$_) . "\" ");
}
basically @array contains some elements that match the first element in the arrays in the AoA, when a match is made the array is stored in @matching_arrays. the output at the moment looks like this (e.g. if @array = ("val1", "val2", "val3"):
Code:
"val1", "sometext", "sometext", "id1"
"val2", "sometext", "sometext", "id2"
"val4", "sometext", "sometext", "id3"
the problem i'm having is displaying the results in a table. i am using cgi.pm the object-oriented way, so the above result should be displayed as a table with 4 columns and 3 rows, and one "element" in each cell.... any hits would be great as i'm pretty stuck