Perl question - How do I print contents of an array on a single line?

I have the following code:

print @testarray;

which returns:

8
8
8
9

How do I return the array like this:

The output is: 8, 8, 8, 9
print "The output is: ", (join ", ", @testarray), "\n";

Or

$"=", "; 
print "The output is: @testarray\n";
printf(("%s " x @testarray) . "\n", @testarray);

Hi Thanks for the help but I am getting the following output:

The output is: 8
, 8
, 8
, 9

Try:

chomp @testarray;
$"=", "; 
print "The output is: @testarray\n";

Yes, thank you! that worked! :slight_smile: