# @c = grep !defined, @c; # is O(N) speed, O(N) memory. # # The following does the same, but # is O(N) speed, O(1) memory. my $last = -1; my $i = -1; while (++$i < @c) { if (defined($c[$i]) { $c[++$last] = $c[$i]; } } $#c = $last; #### pop @c while $#c > $last;