while( @array ) { my ( $even, $odd ) = splice @array, 0, 2; push @odd, $odd if defined $odd; push @even, $even if defined $even; }