while (my ($x,$y) = splice(@list, 0, 2)) { do something with $x and $y }