Jenda Krynicky wrote:
> From: "Dr.Ruud" <[EMAIL PROTECTED]>
>> "Jenda Krynicky" schreef:
>>> Rob Dixon:
>>>>
>>>>   local $" = ',';
>>>>   print "@array\n";
>>>
>>> print join(',', @array), "\n";
>>>
>> is much cleaner and safer. Leave $" alone.
>> I don't agree. It is totally fine to use a local-ed $", if it is inside
>> a minimal block.
> 
> Is it? What if the array you're gonna print is tie()d? Maybe it is 
> not now, but what if it becomes later? To share the array between 
> threads/processes, to store it on disk, to ...
> 
> If there was no simple and clear way to print the array with a 
> specific delimiter, I'd say go ahead. But there is. A way that's much 
> easier to understand. Without having to know about an obscure builtin 
> variable that affects the way arrays are interpolated into strings.

A program with arrays that are tied in one place and not in another has bigger
problems than this anyway. But I don't see a problem with using $" with tied
arrays, unless the tied class happens to overload stringification.

  print join(',', @array), "\n";

is a lot noisier and IMO clumsier than

  {
    local $" = ',';
    print "@array\n";
  }

and after all, even if you don't know what $" does it's very simple to look it
up and also easy to remember.

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to