develooper Front page | perl.perl5.porters | Postings from October 2013

Re: deprecate say!

Thread Previous | Thread Next
Ed Avis
October 7, 2013 15:30
Re: deprecate say!
Message ID:
Zefram <zefram <at>> writes:

>>Hang on - are you saying that *every* use of print in library code needs to
>>be protected by localizing $\, or else document that the library's behaviour
>>is affected by $\'s global value?
>Yes.  Also $, if it prints a list.

Ouch!  I assumed that these were like $[, back in the days when $[ existed.
That is, a weird global setting that perturbs the behaviour of the perl
interpreter in some way that will surely mess up everyone's code, and so
should not be set except for golfing, quick hacks, and oddities like a2p.

If, on the other hand, they are a legitimately changeable part of the
environment which library code should gracefully cope with (like, for example,
whatever value $_ may hold on entering a routine), then a *lot* of code
needs to change.  Not even perlcritic with all its pedantry recommends
armour-plating your code to guard against someone else changing $\ or $,
before calling it.  (I would also add $" to the list.)

Ed Avis <>

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About