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

Re: Deprecation of ${^ENCODING}

Thread Previous
From:
ilmari
Date:
June 8, 2017 10:01
Subject:
Re: Deprecation of ${^ENCODING}
Message ID:
d8jh8zqer4e.fsf@dalvik.ping.uio.no
Sawyer X <xsawyerx@gmail.com> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About