You have several options. The most generic is to join them with join
function:
print join(',', @list), "\n";
The other way is to modify special variables, which affect print
statement. For example, the effect of the above one may be achieved with
$, = ",";
$\ = "\n";
print @list;
You can also automatically join list if it undergoes double-quoted expansion:
$" = ",";
print "@list","\n";
Note that if you modify special variables like $,
, $\
or $"
, you set them globally. To avoid it, use local
keyword and enclose the operands in a block.