This code is broken, and only does the right thing because of the 1/2/3 nature of the example. Use this patch (only a few lines have changed, so it should be human readable) to get it to work for all cases.
RCS file: /home/perl/tools/Cartesian.pm,v retrieving revision 1.2 diff -r1.2 Cartesian.pm 30c30,31 < my $sizes = []; --- > my $div = []; > my $mod = []; 33,34c34,36 < push @$sizes, scalar(@$lref); < $total *= $sizes->[-1]; --- > push @$div, $total; > push @$mod, scalar(@$lref); > $total *= $mod->[-1]; 37,38c39,42 < $self->{sizes} = $sizes; < $self->{count} = $total; --- > $self->{div} = $div; > $self->{mod} = $mod; > $self->{total} = $total; > $self->{count} = 0; 44,45c48,49 < my $c = $self->{count}--; < return undef unless $c; --- > my $c = $self->{count}++; > return undef if ($c == $self->{total}); 48c52 < push @$ret, $self->{arr}->[$i]->[$c % $self->{sizes}->[$i]]; --- > push @$ret, $self->{arr}->[$i]->[($c / $self->{div}->[$i]) % + $self->{mod}->[$i]];
Woops

In reply to Broken, except for trivail cases (such as the example) by jackdied
in thread Name Me! MixMatch? by jackdied

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.