dynamic index for array in while loop

Hi,

I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting an error "Missing -."

Here is the code I have:

set array = `cat file | xargs -n3`
set counter=1
while ($counter <= $#arraysize)
  set a = ${array[$counter]}
  set b = ${array[$counter + 1]}
  set c = ${array[$counter + 2]}
end
 

I've also tried set b = ${array[`expr ${counter} + 2`]} or b = ${array[`expr $counter + 2`]} but they all give me the same "Missing -." error.

UPDATE: Ugh...nevermind, I figured out an ugly kludge. Sorry for bothering y'all. You can delete this thread if you want.