else { /* Use the regular global */
SvREFCNT_dec(PL_encoding);
if (SvOK(sv) || SvGMAGICAL(sv)) {
+ if (PL_localizing != 2) {
+ Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+ "Setting ${^ENCODING} is deprecated");
+ }
PL_encoding = newSVsv(sv);
}
else {
As of Perl 5.20.0 this is a fatal error, to allow future versions of Perl
to use non-integer refs for more interesting purposes.
+=item Setting ${^ENCODING} is deprecated
+
+(D deprecated) You assiged a non-C<undef> value to C<${^ENCODING}>.
+This is deprecated for the same reasons L<encoding> is deprecated.
+
=item shift on reference is experimental
(S experimental::autoderef) C<shift> with a scalar argument is experimental
The I<object reference> to the C<Encode> object that is used to convert
the source code to Unicode. Thanks to this variable your Perl script
-does not have to be written in UTF-8. Default is I<undef>. The direct
-manipulation of this variable is highly discouraged.
+does not have to be written in UTF-8. Default is I<undef>. Setting
+this variable to any other value is deprecated.
This variable was added in Perl 5.8.2.
use warnings 'uninitialized';
$ENV{FOO} = undef; # should not warn
EXPECT
+########
+${^ENCODING} = 42;
+{ local ${^ENCODING}; }
+${^ENCODING} = undef;
+{ local ${^ENCODING} = 37; }
+no warnings 'deprecated';
+${^ENCODING} = 42;
+{ local ${^ENCODING}; }
+${^ENCODING} = undef;
+{ local ${^ENCODING} = 37; }
+EXPECT
+Setting ${^ENCODING} is deprecated at - line 1.
+Setting ${^ENCODING} is deprecated at - line 4.
use tests 4; # rw ${^LETTERS} variables
for(qw< CHILD_ERROR_NATIVE ENCODING UTF8CACHE WARNING_BITS >) {
+ no warnings 'deprecated'; # ENCODING is deprecated;
my $name = s/./"qq|\\c$&|"/ere;
local $$name = 'swit';
# Poor man's "use encoding 'ascii'".
# This causes a different code path in S_const_str()
# to be used
+ no warnings 'deprecated';
local ${^ENCODING} = $enc;
+ use warnings 'deprecated';
use re 'eval';
ok($ss =~ /^$cc/, fmt("encode $u->[2]", $ss, $cc));
}
plan tests => 2 * (4 ** 3 + 4 + 1) * (keys %mbchars);
for my $enc (sort keys %mbchars) {
+ no warnings 'deprecated';
local ${^ENCODING} = find_encoding($enc);
+ use warnings 'deprecated';
my @char = (sort(keys %{ $mbchars{$enc} }),
sort(values %{ $mbchars{$enc} }));