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 { $_ } @Array; " "A" "B" "C"
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 { length } @Array; " Use of uninitialized value in length at -e line 1. "A" "B" "0" "C" "0"
>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"
In reply to Re^4: How do I output each Perl array element sourrounded in quotes?
by AnomalousMonk
in thread How do I output each Perl array element sourrounded in quotes?
by boom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |