Exploring Perl Libraries
by Robert Kiesling

Listing One
(a)
*main::MainWindow:: =>
  { InitBindings =>
*MainWindow::InitBindings
    viewable =>
*MainWindow::viewable
   ::_configure =>
*MainWindow::_configure
    *etc*
  }

(b)
if( exists  ${*IO\:\:File\:\:}{VERSION} ) {
    my( $version_name, $module_version ) =
           %{*IO\:\:File\:\:}{VERSION};
}

(c)
my ($array_key, $array_val) = %{*Module\:\:array};
my $array_name = ${*{$array_val}{SCALAR}};
my $array_contents = @{*{$array_val}{ARRAY}};

(d)
foreach ( my ($key, $val) = %{*Module\:\:} ) {
  local (*entry) = $val;
  if( defined *entry{ARRAY}) {
    foreach( @{*entry{ARRAY}} ) {print "$_, "; }
  }
  if( defined *entry{HASH}) {
    foreach( my ($key_1, $val_1) = %{*entry{HASH}}) {
      print "$key_1=>$val_1, ";
    }
  }
  if( defined *entry{SCALAR}) {
    print ${*entry{SCALAR}}."\n";
  }
Listing Two
(a)
package extraModule;
require Exporter;
@EXPORT=qw(readData);
@EXPORT_OK=qw(VERSION ISA);
sub readData{
   ... _program code_ ...
}

(b)
package mainModule;
use extraModule qw(VERSION ISA readData);

(c)
my $extra_data = ExtraModule::readfile( $filename );
Listing Three
(a)
my %keylist;
# Create a new namespace for package $pkg.
unless( exists ${"$pkg\:\:"}{VERSION} ) {
    eval "package $pkg";
    eval "use $pkg";
    eval "require $pkg";
}
while( my ($key, $val) = each %{*{"$pkg\:\:"}} ) {
    if( defined $val ) {
        local (*v) = $val;
        # test for $pkg to make sure we get the right stash.
    if( ($val =~ /$pkg/) && ($val =~ /VERSION/ ) ) {
        $m -> {version} = ${*v{SCALAR}};
    }
    if( ($val =~ /$pkg/) && ($val =~ /ISA/ ) ) {
        $m -> {superclasses} = "@{*v{ARRAY}}";
        }
    $keylist{$key} = $val;
    }
}

(b)
eval "package Lib::Module";
eval "use Lib::Module";
eval "require Lib::Module";
Listing Four
(a)
package Lib::Module;
sub new {
    my $proto = shift;
    my $class = ref( $proto ) || $proto;
    my $self = {
    children => [],
    parents => '',
    pathname => '',
    basename => '',
    packagename => '',
    version => '',
    superclasses => undef,
    baseclass => '' };
    bless( $self, $class);
    return $self;
}

(b)
package Tk::Browser;
use Lib::Module;

my $m = new Lib::Module;
$m -> module_info( $packname );

(c)
package Tk::Browser;
my $m = &Lib::Module::module_info( $packname );




