for (my $i=0; $i<=$#elements; $i+=2) { # do something with $elements[$i] and $elements[$i+1] } # for