foreach my $element (@$row) { chomp($element); ### remove the newline print "$element,"; ### print it with a comma } print "\n";