On 7/14/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
Chas Owens wrote:
>
> On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
>>
>> Chas Owens wrote:
>>>
>>> By the way, an easier way to write the join version is
>>>
>>> print map { "$_\n" } @list;
>>>
>>
>> BTW, that's not the same. Join inserts its string between each element,
>> map (in this case) appends it to the end. A subtle difference that may
>> lead to confusion and errors.
> snip
>
> The code I am referring to is
>
> print +(join "\n", @LIST), "\n" ;
>
> Which does the same thing as
>
> print map { "$_\n" } @list;
>
> The only difference between them is if $, is set.
No it doesn't. As Shawn said, the join doesn't append a newline
after the last element.
Rob
No, it doesn't, but there is an extra "\n" being tacked on after the
join. This is sloppy and confusing, which is why the map version is
better. the join function is not the right function to use here. If
the join character was ",", then join would be appropriate.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/