in reply to Re: Printing Array with quote and comma
in thread Printing Array with quote and comma
[''];
The map style solutions don't have this problem.
As pointed out below, the map solutions would take more memory, as they are creating an extra copy of your array. If you don't mind updating your array however, you could quote the elements in-place before hand.
my @arr = qw(book dog cat); s/.*/'$_'/ for @arr; print "[" . join(',', @arr) . "];\n";
|
|---|