develooper Front page | perl.perl5.porters | Postings from October 2003

[perl #24139] Symbol Table entry always return defined for {SCALAR}!!!

Thread Next
Graciliano M. P.
October 6, 2003 23:02
[perl #24139] Symbol Table entry always return defined for {SCALAR}!!!
Message ID:
# 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: >

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:

If you set the array and hash before
  @test = %test = 1 ;

it prints:

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:

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),
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!

Graciliano M. P.

You can see this posted at and see what they say:

Please, fix perlbug for Win32, or add a post form at!!!

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About