in reply to Maintain a certain number of elements inside an array?
Perhaps if you showed your code, we might be of more service...
The only thing I can think of without your example source is a little something that irked me when I first started...
Variables in Perl are, by default, "global" in a sense. In other languages, the scope of a variable is, by default, local to the subroutine or class or whatever is using the variable....
So, if you don't re-initialize a variable each time a subroutine fires, it might still have residual values from a previous iteration of the subroutine, thus you get unpredictable array results, etceteras.
That's about all I can offer, without seeing your code...
--higle