e.g. @a = (1,2,3,undef,5); print $#a; @b = map(defined, @a); print join(',',@b);