in reply to changing value to ones on array

I'm having a hard time understanding the question. You're not printing "$total_array" anywhere. Could you post the whole program?

And while you're at it, you may want to check out "perldoc perlstyle" as the wisdom therein will make your code much easier to read.