in reply to How do I reset an array?

You might work on a splice of your array like @arry[1..@#arry] in your for loop
but as I wonder why you are doing all lines again and again - did you consider to use Math::Matrix ? {grin}

Have a nice day
All decision is left to your taste