The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Globwalker - Perl module to explore the contents of the Perl symbol table.

SYNOPSIS

  use Globwalker qw(get_subs get_arrays);

  my @subs = get_subs;          # List of subs in calling package
  @subs = get_subs('Another')   # List of subs in package 'Another'

  my @arrs = get_arrays;        # List of subs in calling package
  @arrs = get_arrays('Another') # List of subs in package 'Another'

DESCRIPTION

Globwalker is a Perl module which allows you to explore the contents of a symbol table.

Globwalker exports six subroutines. Of these, five will list the objects of a particular type (subroutines, scalars, arrays, hashes and filehandles). These subroutines all take an optional argument which is the name of the package whose symbol table should be explored. If this this parameter is omitted then GlobwWalker will explore the symbol table of the package which it is called from.

The sixth subroutine is called get_things and is more generalised. It takes a mandatory parameter which is the type of object to look for (this can be CODE, SCALAR, ARRAY, HASH or IO) followed by the usual optional package name.

Each of these subroutines returns a list containing the names of the objects of the given type which are found in the given package.

A Note About Scalars

Scalars are handled differently than all of the other types that can live in a typeglob. The difference is that each typeglob automatically comes with its own built-in scalar for free - even if you don't use it. Therefore, if you use an array called @x, then there is now way of knowing whether or not the associated scalar ($x) has been defined. The situation is actually slightly worse than that becasue it means that all of the standard filehandles (like STDIN) that exist in the main package will have associated scalars (like $STDIN).

In current versions of Perl there is no way to get round this restriction, so I've made the decision to only return scalar names if their value i defined. This means that if you declare a scalar but don't assign a value to it, then it won't be listed in the return value of get_scalars or get_things('SCALAR').

AUTHOR

Dave Cross <dave@dave.org.uk>

SEE ALSO

perl(1).