It's not a newline problem. In your second section, the line print @new_array . "\n" has @new_array in scalar context, because the string concatenation operator (.) puts its arguments in scalar context. The line is actually executed as print scalar(@new_array) . "\n". In scalar context, you get the array length, which is 5 in this case.
If you want to print a newline after the array, just use a comma:
print @new_array, "\n";
In reply to Re: arrays and dot operator
by vrk
in thread arrays and dot operator
by rkappler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |