in reply to Controlling the Size of an Array based on its file source.
which will fill @arrays with anonymous arrays smaller than 24 Kbytes worth of data (Except when the lines are bigger than 24 Kbytes by themselves) .my @arrays = ( [] ); my $length = 0; while (<>) { if (length $_ + $length >= 24 * 1024) { push @arrays,[$_]; $length = length $_; } else { push @{$arrays[-1]},$_; $length += length $_; } }
Controlling the actual size of the arrays (in terms of allocated memory) is quite a lot trickier (if at all possible) in pure perl.
Another question would of course be: why would you want this anyway?
-- Joost downtime n. The period during which a system is error-free and immune from user input.
|
|---|