in reply to Re: difference between @array."\n" and @array "\n"
in thread difference between @array."\n" and @array "\n"
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: difference between @array."\n" and @array "\n"
by ikegami (Patriarch) on Aug 27, 2009 at 22:09 UTC | |
by LanX (Saint) on Aug 27, 2009 at 22:17 UTC |