my @newArray; foreach my $element ( @array ) { push $element, @newArray if defined $element and $element ne ''; }