sathiya.sw has asked for the wisdom of the Perl Monks concerning the following question:

I am experimenting with the Devel::Symdump which is basically for dumping the symbol table.

My code is this:
use Devel::Symdump; $obj = Devel::Symdump->rnew(); $string = $obj->as_string; print $string . "\n"; print "What is this? $+\n"; print "What is this? $^O\n";
And the output is:
arrays Carp::CARP_NOT Carp::EXPORT Carp::EXPORT_FAIL Carp::EXPORT_OK Carp::ISA Config::EXPORT Config::EXPORT_OK DB::args lib::ORIG_INC main::+ main::- main::ARGV main::INC main::_ functions Carp::carp Carp::cluck Carp::confess Carp::croak Carp::export_fail Carp::longmess Carp::shortmess Config::AUTOLOAD Config::DESTROY Config::FETCH Config::TIEHASH Config::import Devel::Symdump::AUTOLOAD Devel::Symdump::DESTROY Devel::Symdump::_doit Devel::Symdump::_inh_tree Devel::Symdump::_isa_tree Devel::Symdump::_partdump Devel::Symdump::_symdump Devel::Symdump::as_HTML Devel::Symdump::as_string Devel::Symdump::diff Devel::Symdump::inh_tree Devel::Symdump::isa_tree Devel::Symdump::new Devel::Symdump::rnew DynaLoader::boot_DynaLoader Exporter::as_heavy Exporter::export Exporter::export_fail Exporter::export_ok_tags Exporter::export_tags Exporter::export_to_level Exporter::import Exporter::require_version Internals::HvREHASH Internals::SvREADONLY Internals::SvREFCNT Internals::hash_seed Internals::hv_clear_placeholders Internals::rehash_seed PerlIO::Layer::NoWarnings PerlIO::Layer::find PerlIO::get_layers Regexp::DESTROY UNIVERSAL::VERSION UNIVERSAL::can UNIVERSAL::isa attributes::bootstrap lib::_get_dirs lib::_nativize lib::import lib::unimport strict::bits strict::import strict::unimport utf8::decode utf8::downgrade utf8::encode utf8::is_utf8 utf8::native_to_unicode utf8::unicode_to_native utf8::upgrade utf8::valid vars::import warnings::Croaker warnings::__chk warnings::bits warnings::enabled warnings::import warnings::register::import warnings::register::mkMask warnings::unimport warnings::warn warnings::warnif hashes Carp::CarpInternal Carp::Internal Config::Config Exporter::Cache lib::Config main::@ main::ENV main::INC main::SIG warnings::Bits warnings::DeadBits warnings::Offsets ios Devel::Symdump::ENTRY main::ARGV main::STDERR main::STDIN main::STDOUT main::_ main::stderr main::stdin main::stdout packages CORE CORE::GLOBAL Carp Carp::Heavy Config DB Devel Devel::Symdump DynaLoader Exporter Exporter::Heavy File File::Spec IO IO::Handle Internals Mac Mac::FileSpec Mac::FileSpec::Unixish PerlIO PerlIO::Layer Regexp UNIVERSAL attributes lib strict utf8 vars warnings warnings::register scalars CORE::GLOBAL:: Carp::CARP_NOT Carp::CarpInternal Carp::CarpLevel Carp::EXPORT Carp::EXPORT_FAIL Carp::EXPORT_OK Carp::Heavy:: Carp::ISA Carp::Internal Carp::MaxArgLen Carp::MaxArgNums Carp::MaxEvalLen Carp::VERSION Carp::Verbose Carp::carp Carp::cluck Carp::confess Carp::croak Carp::export_fail Carp::longmess Carp::longmess_heavy Carp::shortmess Carp::shortmess_heavy Config::AUTOLOAD Config::BEGIN Config::Config Config::DESTROY Config::EXPORT Config::EXPORT_OK Config::FETCH Config::TIEHASH Config::config_re Config::config_sh Config::config_vars Config::import Config::launcher Config::myconfig DB::args Devel::Symdump:: Devel::Symdump::AUTOLOAD Devel::Symdump::BEGIN Devel::Symdump::DESTROY Devel::Symdump::Defaults Devel::Symdump::ENTRY Devel::Symdump::MAX_RECURSION Devel::Symdump::VERSION Devel::Symdump::_doit Devel::Symdump::_inh_tree Devel::Symdump::_isa_tree Devel::Symdump::_partdump Devel::Symdump::_symdump Devel::Symdump::as_HTML Devel::Symdump::as_string Devel::Symdump::diff Devel::Symdump::import Devel::Symdump::inh_tree Devel::Symdump::isa_tree Devel::Symdump::new Devel::Symdump::rnew DynaLoader::boot_DynaLoader Exporter::Cache Exporter::Debug Exporter::ExportLevel Exporter::Heavy:: Exporter::VERSION Exporter::Verbose Exporter::__ANON__ Exporter::as_heavy Exporter::export Exporter::export_fail Exporter::export_ok_tags Exporter::export_tags Exporter::export_to_level Exporter::import Exporter::require_version File::Spec:: IO::Handle:: Internals::HvREHASH Internals::SvREADONLY Internals::SvREFCNT Internals::hash_seed Internals::hv_clear_placeholders Internals::rehash_seed Mac::FileSpec:: Mac::FileSpec::Unixish:: Mac::FileSpec::Unixish::nativize PerlIO::Layer:: PerlIO::Layer::NoWarnings PerlIO::Layer::find PerlIO::get_layers Regexp::DESTROY UNIVERSAL::VERSION UNIVERSAL::can UNIVERSAL::import UNIVERSAL::isa attributes::bootstrap lib::BEGIN lib::Config lib::ORIG_INC lib::VERSION lib::_get_dirs lib::_nativize lib::import lib::unimport main::^H main::^O main::^R main::^V main::^W main::^WARNING_BITS main::^X main::! main::" main::$ main::+ main::- main::/ main::0 main::1 main::<none>:: main::@ main::ARGV main::BEGIN main::CORE:: main::Carp:: main::Config:: main::DB:: main::Devel:: main::DynaLoader:: main::ENV main::Exporter:: main::File:: main::INC main::IO:: main::Internals:: main::Mac:: main::PerlIO:: main::Regexp:: main::SIG main::STDERR main::STDIN main::STDOUT main::UNIVERSAL:: main::] main::_ main::_<perlio.c main::_<perlmain.c main::_<universal.c main::_<xsutils.c main::attributes:: main::lib:: main::main:: main::obj main::stderr main::stdin main::stdout main::strict:: main::string main::utf8:: main::vars:: main::warnings:: strict::VERSION strict::bits strict::import strict::unimport utf8::decode utf8::downgrade utf8::encode utf8::is_utf8 utf8::native_to_unicode utf8::unicode_to_native utf8::upgrade utf8::valid vars::BEGIN vars::VERSION vars::import warnings::All warnings::BEGIN warnings::BYTES warnings::Bits warnings::Croaker warnings::DeadBits warnings::LAST_BIT warnings::NONE warnings::Offsets warnings::VERSION warnings::__chk warnings::bits warnings::enabled warnings::import warnings::register:: warnings::register::VERSION warnings::register::import warnings::register::mkMask warnings::unimport warnings::warn warnings::warnif unknowns What is this? What is this? linux
Here are my questions.

Arrays prints under arrays. Hashes prints under hash - It is ok.
1. But Why does most of the identifiers are getting printed under the scalars. ( check some package names are also printed under the scalars, if it is printed under packages it is right, but why here ?? )

2. Only the package names ends with :: in the identifier, why is it so ?? others does not.

3. While trying to print the scalars, some got printed and some does not. Why +, - are used as default, and what is the use of it. ??

Sathiya

Replies are listed 'Best First'.
Re: Devel::Symdump - doubts in the output got.
by gone2015 (Deacon) on Dec 08, 2008 at 11:29 UTC
    1. But Why does most of the identifiers are getting printed under the scalars. ( check some package names are also printed under the scalars, if it is printed under packages it is right, but why here ?? )

    I suspect that all the identifiers are getting printed under "scalars"...

    Background: the entry for an identifier is a reference to a GLOB (unless it's a late model 'constant', in which case it may be a reference to a SCALAR, ARRAY or HASH). A GLOB contains a pointer to the various different things that the identifier may refer to -- SCALAR, ARRAY, HASH, CODE, etc -- and the (eg) *foo{HASH} construct will return the respective pointer.

    Kicker: for everything except SCALAR, (eg) *foo{HASH} will return undef when no HASH has been defined. For SCALAR the pointer is always defined, but the value it points to may be undef. This means that it's not possible to distinguish between a SCALAR that has been declared but whose value is undef, and a SCALAR that has never actually been declared.

    I had a look at Devel::Symdump. It thinks that a SCALAR exists if the pointer *ENTRY{SCALAR} is defined. It could test to see if what is pointed to is also defined, but then it would miss a declared SCALAR which has not yet been defined. There just isn't a completely right answer to this :-(

    2. Only the package names ends with :: in the identifier, why is it so ?? others does not.

    This is easier... you may be thinking of the '::' as separators. In effect they are part of the package name. But, since they come at the end of the name they can also be treated as separators...

    3. While trying to print the scalars, some got printed and some does not. Why +, - are used as default, and what is the use of it. ??

    I'm sorry, you lost me here... If you mean that you tried printing the scalar value of everything listed as a Scalar by Devel::Symdump, then the above explains why many will have undef SCALAR parts.

    As for what $+ and $^O are, I refer you to perlvar.