in reply to not able to get last index of array

Your use of join means that the array @a has only one element which is a big long string. Omit the join and you should get a bit farther.