How annoying. The code doesn't have a clean way of doing 'X'. Therefore I need to add this feature. Hmm ... it appears that I need to add it in a Mason component that's not tested. That's even more annoying. Then the final annoyance: seeing, for the first time, the actual code that I must change.
# push in first row (always the same as the default options) push(@{$advanced_options[0]}, @report_options); my $i = 1; my ($day_range_rev_option) = grep { $_->cgi_name =~ /day_range_rev/ } @options; @options = grep { $_->cgi_name !~ /day_range_rev/ } @options; while (scalar @options > 0) { my @current_options = (); if (scalar @report_options >= 3) { @current_options = splice(@options, 0, 3); } else { @current_options = splice(@options, 0, scalar @options); } push(@{$advanced_options[$i++]}, @current_options); } push(@{$advanced_options[$i++]}, ($day_range_rev_option)) if ($day_range_rev_option);
Um, yeah.
Update: As it turns out, after much puzzling over what was intended, it turns out that the while loop reduces down to this:
while (@options) { push @advanced_options => [splice @options, 0, 3]; }
For nice effect one might also try:use List::Group qw[group];
my @advanced = group \@options, cols => 3; # rows => 3
Ah well...use HTML::Table;
my $table = HTML::Table->new(-data => \@advanced);
# elsewhere in some mason world
<% $table %>