Phoenix.pm: More symbol table weirdness

Beaves at aol.com Beaves at aol.com
Thu Feb 10 10:15:09 CST 2000


Doug,

It may be because your sub needs to be recursive to catch the definedness of 
nested packages in a symbol table.

How about something like this...

&print_or_expand('XML_ObjTree');

sub print_or_expand  {
    local $symname = shift;
    print "\nPrinting or expanding the contents of %$symname\n";
    foreach $name ( keys %{$symname} )  {
        print "The key '$name' in the symbol table %$symname " .
            "points to ${$symname}{$name}";
        print " (it is defined)" if defined ${$symname}{$name};
        if ($name =~ /::$/)  {
            print "\nIts another symbol table, let's do this again...\n";
            &print_or_expand;
        } else {
            print "\nIt points to a glob (${$symname}{$name}), lets see the 
details\n";
            local *sym = ${$symname}{$name};
            print "\t\$$package is defined\n" if defined $sym;
            print "\t\@$package is defined\n" if defined @sym;
            print "\t\%$package is defined\n" if defined %sym;
            print "\t\&$package is defined\n" if defined &sym;
        }
    }
}

I have not tested this thing out, so all bets are off!  But it may give you 
some ideas.  Let me know more about what you find out...

Tim









More information about the Phoenix-pm mailing list