The . operator is the string concatenation operator, so @array . "\n" stringifies @array and adds "\n" to the end, which returns scalar(@array) . "\n", i.e. the count of elements in @array and a "\n".
Not 100% correct ... :)
"scalar(@array)"? Yes!
"stringifies @array"? No!
It's more like stringifies scalar(@a) ...
DB<26> @a=1..3 DB<27> p scalar @a 3 DB<28> p "@a" 1 2 3 DB<29> p @a."\n" 3 DB<30> p "@a"."\n" ; # $" is separator for stringification 1 2 3 DB<31> print "@a\n" 1 2 3 DB<32> p @a,"\n" ; # $, is separator for print args 123 DB<33> p "@a","\n" 1 2 3
Cheers Rolf
UPDATE: From perlop#Operator Precedence and Associativity:
"With very few exceptions, these¹ all operate on scalar values only, not array values."
(1) = perl operators
In reply to Re^2: difference between @array."\n" and @array "\n"
by LanX
in thread difference between @array."\n" and @array "\n"
by NileshJ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |