for $i (0..7) {
do stuff to 3*$i;
do stuff to 3*$i+1;
do stuff to 3*$i+2;
}
This would be a little bit more efficient than what you have written. For small numbers of iterations, you probably won't notice a difference, but it can start to slow things down if the situation gets large.