(perl #130674) don't modify $^H in vars.pm

This could remove non-vars strictness from the caller.
This commit is contained in:
Tony Cook 2017-02-01 16:31:02 +11:00
parent 4e3855f131
commit eda3f954e1
2 changed files with 10 additions and 3 deletions

View File

@ -2,7 +2,7 @@ package vars;
use 5.006;
our $VERSION = '1.04';
our $VERSION = '1.05';
use warnings::register;
use strict qw(vars subs);
@ -20,7 +20,7 @@ sub import {
Carp::croak("Can't declare individual elements of hash or array");
} elsif (warnings::enabled() and length($sym) == 1 and $sym !~ tr/a-zA-Z//) {
warnings::warn("No need to declare built-in vars");
} elsif (($^H &= strict::bits('vars'))) {
} elsif (($^H & strict::bits('vars'))) {
require Carp;
Carp::croak("'$_' is not a valid variable name under strict vars");
}

View File

@ -8,7 +8,7 @@ BEGIN {
$| = 1;
print "1..27\n";
print "1..28\n";
# catch "used once" warnings
my @warns;
@ -103,3 +103,10 @@ print "${e}ok 26\n";
$e = !(grep(/^Global symbol "\%w" requires explicit package name/, @errs))
&& 'not ';
print "${e}ok 27\n";
{
no strict;
eval 'use strict "refs"; my $zz = "abc"; use vars qw($foo$); my $y = $$zz;';
$e = $@ ? "" : "not ";
print "${e}ok 28 # use vars error check modifying other strictness\n";
}