Re: $OUTPUT_RECORD_SEPARATOR strikes against LWP

Tim Bunce (Tim.Bunce@ig.co.uk)
Fri, 26 Apr 1996 11:55:44 +0000


> From: Gisle Aas <aas@bergen.sn.no>
> 
> In message <199604251754.TAA02572@anna.in-berlin.de>, Andreas Koenig writes:
> > there must be still a place in libwww, where you print without setting
> > $\ locally to "".
> 
> The same problem applies to $, $# and $" I guess.
> 
> Perhaps we should start to use syswrite() instead of print in
> libraries :-)
> 
> There are also places in libwww-perl where I do:
> 
>   while (<FILE>) { ... }
> 
> without setting $/ locally to "\n".
> 
> I guess we also have worry about somebody setting $* to 1?

Yeap.

> Perhaps every library module should start out with these lines:

To be effective that would have to be every library _function_!

>   local($_);
>   local($/) = "\n";
>   local($#) = "%.20g";
>   local($,) = "";
>   local($\) = "";
>   local($*) = 0;

Or local($/, $#, $,, $\, $*, $_) = ("\n", "%.20g", "", "", 0); but
it's still too much hassle and expense to consider for every function.

Basically it boils down to trust, good-practice and documentation.

> or perhaps we can get perl to treat all these special variables like
> it treats $[?
> 
> I was surprised about this behaviour:  perl -le '$# = 666; print 42'

Eeek!

Anyone using Safe should take care to localise special variables if
appropriate. I'll see if I can provide some efficient automation for it.

Tim.