http://qs321.pair.com?node_id=30292


in reply to How do I print an array with commas separating each element?

Here's another way:

my $x = 0; printf "$array[$x-1]%s", $x <= $#array ? "," : "\n" while $array[$x++];

It puts a newline instead of a comma after the last element.