my @array = qw/one two three four five/; $array[2] = undef; # undefine one of the elements. print scalar grep { defined $_ } @array; __OUTPUT__ 4