#!/usr/bin/perl use strict; use warnings; my @array = (undef,1,undef,2,undef,3); @array = grep { defined $_ } @array; print "@array\n";