Hopefully these nodes will help you as they did me.
In reply to Re: $#{$array_ref} changes in loop by chakram88 in thread $#{$array_ref} changes in loop by thomc