in reply to 2D arrays

Perl's 2d arrays are actually arrays of array references. Each array reference, when dereferenced will contain 38 elements. perllol has a full description of manipulating "lists of lists". And perlreftut as well as perlref will get you started on dealing with references.

You might inspect the output like this:

my @output = sortList( @flatlist ); foreach my $array_ref ( @output ) { print "@{$array_ref}\n"; }

Another way to write your "38 at a time" code is to use List::MoreUtils natatime function, like this:

use strict; use warnings; use List::MoreUtils qw( natatime ); my @biglist = (1 .. 1444); foreach my $array_ref ( sortList( @biglist ) ) { print "@{$array_ref}\n"; } sub sortList { my $it = natatime 38, @_; my @output; while ( my @sublist = $it->() ) { push @output, \@sublist; } return @output; }

Dave