in reply to splitting 2D array into chunks

I agree your question is badly posed; I, at least, don't really understand the details.

See How to ask better questions using Test::More and sample data. You might start with something like

use strict; use warnings; use Test::More 'tests' => <number of tests>; use Test::NoWarnings; # adds 1 test use Data::Dumper; # for debug my @al = (...); my @distribution = ( 3, 4, 5, 5, 6, 6, 8, 10, ); my $ar_expected_output = ( [ ... ], [ ... ], ... ); my $ar_got_output = distribute(\@al, \@distribution); is_deeply $ar_got_output, $ar_expected_output; exit; # subroutines ############################################# sub distribute { my ($ar_input, # array ref.: input array $ar_distribution, # array ref.: distribution to output arrays ) = @_; my @output; ... return \@output; }
Construct the output arrays first and test the process. Once you have the output arrays constructed, it should be fairly straightforward to output them to files.

See also Short, Self-Contained, Correct Example and Perl Data Structures Cookbook.

See perlintro for basic file I/O stuff, open and perlopentut for more advanced stuff.

Maybe also see I know what I mean. Why don't you?


Give a man a fish:  <%-{-{-{-<