NAME

Array::Reform - Convert an array into N-sized array of arrays

SYNOPSIS

use Array::Reform;

@sample = ( 1 .. 10 );
$rowsize = 3;

Array::Reform->reform( $rowsize, \@sample );
    =>
       (
          [   1,   2,   3   ],
          [   4,   5,   6   ],
          [   7,   8,   9   ],
          [   10   ]
        );

Array::Reform->dissect( $rowsize, \@sample );
    =>
       (
          [   1,   5,   9   ],
          [   2,   6,  10   ],
          [   3,   7   ],
          [   4,   8   ]
        );

DESCRIPTION

Both these methods are designed to reformat a list into a list of lists. It is often used for formatting data into HTML tables, amongst other things.

The key difference between the two methods is that dissect() takes elements from the start of the list provided and pushes them onto each of the subarrays sequentially, rather than simply dividing the list into discrete chunks. As a result dissect() returns a list of lists where the first element of each sublist will be one of the first elements of the source list, and the last element will be one of the last. This behaviour is much more useful when the input list is sorted.

AUTHOR

The original code was written by the Perl Monks user lhoward, with contributions by adam, swiftone, and crystalflame. It was uploaded by princepawn.

This version was written by kilinrax, with contributions from davorg.

SEE ALSO

http://perlmonks.org/ --- quick answers to your Perl questions.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 90:

Deleting unknown formatting code T<>

Deleting unknown formatting code T<>