If I understand your problem correctly, then you might wish to consider using a hash instead. Maybe use the string as the key and the value could be a reference to an array of positions.
Comment on Re: appending and array into last element of an array?