I am having trouble finding the most efficient way to complete the following task. I have an array @array with entries (x, x, y, z, z, z) and I want to grab the indices of the array that correspond to the first and last of each identical value. Thus, for this example I want to make an array that has the values (0, 1, 2, 2, 3, 5). Any help would be greatly appreciated.