my @arr = qw(book dog cat); print "['" # Print the leading bracket and quote . join("','", @arr) # join array with quotes and commas . "'];\n"; # print the trailing quote, bracket, etc.