my @array = 1 .. 1_000_000; ## Note the above doubles mem. consumption. ## Half of which is immediately availble to the rest of the program. # Ripple the good values through the array my( $s, $d ); for( $s = $d = 0; $s < @array; $d++, $s++ ) { $array[ $s ] %2 and $s++;; $array[ $d ] = $array[ $s ]; }; # and truncate it. $#array = --$d;