diff options
author | Tony Cook <tony@develop-help.com> | 2017-02-01 16:31:02 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2018-09-26 14:39:52 +1000 |
commit | eda3f954e1ab1728381b70aa008fe2226fd05de2 (patch) | |
tree | 7a14ee08412e3f1e4e9a7a83f08994922b4e78c4 | |
parent | 4e3855f131e01fb258a8cb812abd6a50fc7fc48b (diff) | |
download | perl-eda3f954e1ab1728381b70aa008fe2226fd05de2.tar.gz |
(perl #130674) don't modify $^H in vars.pm
This could remove non-vars strictness from the caller.
-rw-r--r-- | lib/vars.pm | 4 | ||||
-rw-r--r-- | lib/vars.t | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/vars.pm b/lib/vars.pm index 5f6c0598ca..1027986fac 100644 --- a/lib/vars.pm +++ b/lib/vars.pm @@ -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"); } diff --git a/lib/vars.t b/lib/vars.t index 3075f8e5ff..9b9822ca28 100644 --- a/lib/vars.t +++ b/lib/vars.t @@ -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"; +} |