my @a = (1,2,3,4,5);
print @a; #output: 12345
print "\n";
print "@a"; #output: 1 2 3 4 5
Run Code Online (Sandbox Code Playgroud)
通过将名称加上双引号来打印数组会在输出的每个索引值之间放置一个空格.它是如何做到的?为什么不print @a;打印相同?两种类型的需求是什么?我的意思是你何时会使用print @a;而不是print "@a";反之亦然.