Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday May 27, 2004
02:44 PM

Plumbing the depths of the code

[ #18972 ]

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];
  }

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • use List::Group qw[group];

    my @advanced = group \@options, cols => 3; # rows => 3
    For nice effect one might also try:
    use HTML::Table;
    my $table = HTML::Table->new(-data => \@advanced);

    # elsewhere in some mason world

    <% $table %>
    Ah well...
    --
    Casey West