develooper Front page | perl.perl5.porters | Postings from June 2017

Re: Deprecation of ${^ENCODING}

Thread Previous
June 8, 2017 10:01
Re: Deprecation of ${^ENCODING}
Message ID:
Sawyer X <> writes:

> I think what this addresses is a developer assuming that undef'ing this
> variable (by applying "undef" to it, undef()'ing it, or local()izing it)
> has an effect. Any such assumption might be worthwhile verifying doesn't
> work by fatalizing. On the other hand, it also means actively breaking
> code that might work just the same. I'm still on the fence, but leaning
> towards leaving it to not have any effect.

Quoth perlvar:

    If you are coming here because code of yours is being adversely
    affected by someone's use of this variable, you can usually work
    around it by doing this:

      local ${^ENCODING};

    near the beginning of the functions that are getting broken. This
    undefines the variable during the scope of execution of the
    including function.

The idea is that you can defend your code against ${^ENCODING} being set
from outside it, and I think makes sense to allow this without having a
version guard.

- Twitter seems more influential [than blogs] in the 'gets reported in
  the mainstream press' sense at least.               - Matt McLeod
- That'd be because the content of a tweet is easier to condense down
  to a mainstream media article.                      - Calle Dybedahl

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