Manual Reference Pages - ARRAY::GROUP (3)
Array::Group - Convert an array into array of arrayrefs of uniform size N.
use Array::Group qw( :all );
@sample = ( 1 .. 10 );
$rowsize = 3;
ngroup $rowsize => \@sample ;
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ],
[ 10 ]
dissect $rowsize => \@sample ;
[ 1, 5, 9 ],
[ 2, 6, 10 ],
[ 3, 7 ],
[ 4, 8 ]
The ngroup method reformats a list into a list of
arrayrefs. It is often used for formatting data into HTML tables, amongst
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.
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.
Both methods can be called as either functions or class methods (to
ensure compatibility with previous releases), and the array to be
reformed can be passed as a reference.
The ongoing saga between princepawn, davorg and kilinrax over who did
when in terms of getting this out is rather long-winded.
They have their side of the story and I have mine. As is usual, it is
princepawn versus some other majority. But what more could you expect from
the black sheep of the Perl community?
One thing is for certain
there is a bug in Array::Reform
and two months have passed and the
author has done nothing about my RT bug patch submitted 1/21/06:
Not to mention that I held the Array::Reform namespace and when I turned it
overto him, he did not even acknowledge this.
The test suite for HTML::Element::Library
depends on this
functionality and since I have people complaining about the wacky errors
coming out of kilinraxs version of this module, and since he does not
respond to emails, it is clear it is time to drop any reliance on his module.
So, I wont say who the author is of what... this is free software anyway.
|perl v5.20.3 ||ARRAY::GROUP (3) ||2011-07-05 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.