I'm wondering if there's a more elegant way of achieving what I'm doing with the code below (somewhat related to my node [366914]):
my $matrix_ref = [[1, a1, z1],[1, a1, z2], [1, a1, z3], [2, a2, z1], [2, a2, z2], [3, a3, z1]];
my ($html_str, $key, $count);
# id, a_item, z_item
foreach my $row (@$matrix_ref) {
if ($row->[0] eq $key) {
$html_str .= qq~$row->[2] \n~;
}
else {
$html_str .= '' if $count > 0;
$html_str .= qq~| $row->[0] |
| $row->[1] |
| $row->[2] |
| $_ |