in reply to Re: Printing Array with quote and comma
in thread Printing Array with quote and comma

This doesn't really work, as if the array contains no elements, your code will still print one empty element...
[''];

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";
---
my name's not Keith, and I'm not reasonable.