Further to davido's discussion of the Perl interpreter's efforts to manage memory for your arrays (and hashes and everything else):
geertvc: Note that if you have an array that starts small and that will grow to a very large size that you know (or can estimate) in advance, it's possible and occasionally advantageous to "pre-grow" the array by assignment to the array's max index via the $# array dereference operator (if that's the correct terminology).
c:\@Work\Perl\monks>perl -wMstrict -le
"my @ra = qw(a b c);
print 'A: array max index: ', $#ra;
;;
$#ra += 1_000_000;
print 'B: array maximum index: ', $#ra;
print 'B: number of array elements: ', scalar @ra;
"
A: array max index: 2
B: array maximum index: 1000002
B: number of array elements: 1000003
See
perldata regarding
$#. In most cases, however, it's best to let the interpreter manage these things on its own.
Give a man a fish: <%-{-{-{-<