# New Ticket Created by "Graciliano M. P." # Please include the string: [perl #24139] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=24139 > Why when you access the {SCALAR} key of a symbol entry in the Symbol Table of a package it always return a scalar reference?! Even if the scalar, or any symbol (array, hash, glob) with this name is not defined! For example: my $name = 'main::test' ; if (defined *{$name}{SCALAR}) { print "\$$name\n" ;} if (defined *{$name}{ARRAY}) { print "\@$name\n" ;} if (defined *{$name}{HASH}) { print "\%$name\n" ;} This prints: $main::test If you set the array and hash before @test = %test = 1 ; it prints: $main::test @main::test %main::test Soo, it always print true for $main::test!!! The worst thing is that it always return a scalar reference: my $name = 'main::test' ; my $ref = *{$name}{SCALAR} ; print "$ref\n" ; This prints: SCALAR(0x1a6f080) Soo, it always create a new scalar in the memory, even if you just want to know if the scalar exists in the memory! This was tested with Perl-5.6.1-Win32, Perl-5.8.1-Win32 (the new release), Perl-5.6.1-Linux. We can see that Devel::Symdump uses if (defined $val && defined *ENTRY{SCALAR}) { to test if a scalar exists. But if the value of the scalar is undef it's says that the scalar is not in the table. And since *ENTRY{SCALAR} always return a scalar ref it's not needed. I think that the behavior doesn't work like it should, since for {ARRAY} and {HASH} it works like we want. At least this need to be documented! Regards, Graciliano M. P. You can see this posted at perlmonks.com and see what they say: http://www.perlmonks.com/index.pl?node_id=297182 Please, fix perlbug for Win32, or add a post form at http://rt.perl.org/perlbug/!!!Thread Next