in reply to adding to the middle of a array

You can use splice:

splice( @a, 5, 0, $newelement)

This will replace the fragment of list at index 5, with a length of 0, with the rest of the arguments, here a single element. See perldoc -f splice for more info.