while (my ($el1, $el2) = splice(@list, 0, 2)) { # do stuff }