diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-05-25 22:44:39 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-06-07 08:18:53 -0700 |
commit | bf3d870f8b8accd379ab520c1ff1daa10317d27d (patch) | |
tree | 5146803b0bf1ed8f28a35e8c6728b09f1ab2710a /t/lib/strict | |
parent | f90b723246c15bceccd726b73c412184c27eca7d (diff) | |
download | perl-bf3d870f8b8accd379ab520c1ff1daa10317d27d.tar.gz |
Make strict refs report $1 the same way as "$1"
A magical variable is never SvPOK, but only SvPOKp. The code that
determined whether to put an ellipsis mark after a truncated symbol
name was only checking SvPOK, resulting in this discrepancy:
$ perl5.15.9 -e 'use strict; *{"a"x40}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...) as a symbol ref while "strict refs" in use at -e line 1.
$ perl5.15.9 -e 'use strict; ("a"x40)=~/(.*)/; *{$1}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as a symbol ref while "strict refs" in use at -e line 1.
$ perl5.15.9 -e 'use strict; ${"a"x40}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"...) as a SCALAR ref while "strict refs" in use at -e line 1.
$ perl5.15.9 -e 'use strict; ("a"x40)=~/(.*)/; ${$1}'
Can't use string ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as a SCALAR ref while "strict refs" in use at -e line 1.
SvPOK variables are also SvPOKp, so checking just the latter suffices.
Diffstat (limited to 't/lib/strict')
-rw-r--r-- | t/lib/strict/refs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/lib/strict/refs b/t/lib/strict/refs index d9bff7cd84..21dbfcfab6 100644 --- a/t/lib/strict/refs +++ b/t/lib/strict/refs @@ -27,6 +27,29 @@ Can't use string ("A::Really::Big::Package::Name::T"...) as a HASH ref while "st # strict refs - error use strict ; +"A::Really::Big::Package::Name::To::Use" =~ /(.*)/; +${$1}; +EXPECT +Can't use string ("A::Really::Big::Package::Name::T"...) as a SCALAR ref while "strict refs" in use at - line 5. +######## + +# strict refs - error +use strict ; +*{"A::Really::Big::Package::Name::To::Use"; } +EXPECT +Can't use string ("A::Really::Big::Package::Name::T"...) as a symbol ref while "strict refs" in use at - line 4. +######## + +# strict refs - error +use strict ; +"A::Really::Big::Package::Name::To::Use" =~ /(.*)/; +*{$1} +EXPECT +Can't use string ("A::Really::Big::Package::Name::T"...) as a symbol ref while "strict refs" in use at - line 5. +######## + +# strict refs - error +use strict ; my $fred ; my $a = ${"fred"} ; EXPECT |