in reply to Final Solution for Generating a container table in HTML::CalendarMonth?
in thread Generating a container table in HTML::CalendarMonth

It is, indeed, as you say - "The Final Solution". I read in awe...

I'm pleased at least that I was on the right lines with  my $row = int( $calnum / 3 );. Unfortunately I had meant to show you the lines:

# Populate container table for my $calnum ( 0 .. $#cals ) { my $row = int($calnum/4); $t->cell( $row, $calnum )->push_content( $cals[$calnum] ); }
but I was in too much of a hurry and pasted the wrong thing:(
I see belatedly that this couldn't have worked because the column numbers are only ever 1 to 3 whereas $calnum is constantly increasing. I have looked in Programming Perl and discovered the modulus operand, but the explanation is rather too opaque for me to understand. Could you explain how it achieves its goal in this case?

Thanks once again for this - I shall not only enjoy - I am thrilled to use it and only hope that one day I might aspire to such things myself.

Replies are listed 'Best First'.
Short Explaination of %
by Mr. Muskrat (Canon) on Apr 01, 2003 at 15:08 UTC

    % or modulus division is very simple.
    my $col = $calnum % 3;
    Divide $calnum by 3 and store the remainder in $col.

    1 % 3 = 1
    2 % 3 = 2
    3 % 3 = 0
    4 % 3 = 1
    ...

      Of course, I see - the remainder always gives the column number. Devious. Brilliant.
      jonnyfolk walks away shaking his head in admiration...