#!/usr/bin/perl -w
######################################################################
# inhMult.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

######################################################################
package Basepac1;                         # first base class

sub new {                                 # constructor
  my $type = shift; 
  my $self = {};
                                          # initialize base
  $self->{'b1'} = "b1";                   # class 1 variable
                                      
  bless $self, $type;
}

######################################################################
package Basepac2;                         # second base class

sub new {                                 # constructor
  my $type = shift; 
  my $self = {};

  $self->{'b2'} = "b2";                   # initialize base
                                          # class 2 variable
  bless $self, $type;
}

######################################################################
package Deripac;                          # derived class

@ISA = qw ( Basepac1 Basepac2 );          # multiple inheritance

sub new {                                 # constructor
  my $type = shift; 
  my $self = {};

  my ($pac, $key);     

  foreach $pac (@ISA) {                   # for all base classes ...
    my $hashref = $pac->new();            # call constructor
                           
    foreach $key (keys %$hashref) {       # merge inherited
        $self->{$key} = $hashref->{$key}; # variables into the
    }                                     # local namespace
  }
 
  bless $self, $type;
}

sub derimethod {                          # output variables
  my $self = shift;

  my $key;

  foreach $key (keys %{$self}) { 
      print "\$self->{'$key'}=", "$self->{$key}\n";
  }
}

######################################################################
package main;                             # main program

$derobj = Deripac->new();                 # call constructor
$derobj->derimethod();                    # output inherited variables

