One thing to keep in mind is that Perl's dynamically growing lists have a memory cost associated with them. It allocates memory in chunks when it thinks it needs more. One result of this is that Perl might allocate for 50 elements, and when you hit element 50 in an array Perl might decide to grab RAM for another 50 elements, just in case you're going to use them.
One way to cut down on array size is to pre-size for the number of elements you expect all in one chunk. I think I recall this was done like so:
$#foo = 100; # expecting 100 elements
All of this is discussed in the back of the Camel in the section on optimizing memory.