I load a file into an array (every line in array element). I process the array elements and save to a new file. I want to print out the new file:
print ("Array: @myArray");
But - it shows them with leading spaces in every line. Is there a simple way to print out the array without the leading spaces?
Matt Fenwick is correct. When your array is in double quotes, Perl will put the value of
$"(which defaults to a space; see the perlvar manpage) between the elements. You can just put it outside the quotes:If you want the elements separated by for example a comma, change the output field separator: