my @arr1 = ("foo", "", "bar", "", "baz"); my @arr2; foreach (@arr1) { push @arr2, $_ if $_ ne ''; }