From eda3f954e1ab1728381b70aa008fe2226fd05de2 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Wed, 1 Feb 2017 16:31:02 +1100 Subject: (perl #130674) don't modify $^H in vars.pm This could remove non-vars strictness from the caller. --- lib/vars.pm | 4 ++-- 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"; +} -- cgit v1.2.1