in reply to Re^3: How do I output each Perl array element sourrounded in quotes?
in thread How do I output each Perl array element sourrounded in quotes?

But grepping on  $_ filters out the string  '0' or a numeric value of 0.

>perl -wMstrict -le "my @Array = ('A', undef, 'B', '0', 'C', 0); print join ' ', map {qq(\"$_\")} grep { $_ } @Array; " "A" "B" "C"
Grepping on length will allow handling of  '0' or 0, but is unhappy with an undefined value (if this should be an issue).

>perl -wMstrict -le "my @Array = ('A', undef, 'B', '0', 'C', 0); print join ' ', map {qq(\"$_\")} grep { length } @Array; " Use of uninitialized value in length at -e line 1. "A" "B" "0" "C" "0"
Grepping on both defined and length handles a broad range of variations.
>perl -wMstrict -le "my @Array = ('A', undef, 'B', '0', 'C', 0); print join ' ', map {qq(\"$_\")} grep {defined and length} @Array; " "A" "B" "0" "C" "0"