my $cur_index = 0; while ( $cur_index <= $#x - 1 ) { my ($x, $y) = @x[$cur_index .. $cur_index + 1]; $cur_index += 2; # Do stuff with $x and $y }