use strict; use warnings; my @array = (1, 2, undef, 4, 5, undef, undef, 8, 9); print join ' ', grep $_, @array; #### 1 2 4 5 8 9