#################################### package iface2; print "\n\n",__PACKAGE__,"\n\n"; use base qw(Class::Virtually::Abstract); __PACKAGE__->virtual_methods(qw(new iface2_method)); 1; __END__ #################################### package iface1; print "\n\n",__PACKAGE__,"\n\n"; use base qw(Class::Virtually::Abstract); __PACKAGE__->virtual_methods(qw(new iface1_method)); 1; __END__ #################################### package class; use base qw(iface1 iface2); # See what methods we're obligated to implement. my @must_implement = __PACKAGE__->virtual_methods; print "\n",__PACKAGE__," must implement @must_implement\n\n"; # Check to make sure this PACKAGE implemented everything my @missing = __PACKAGE__->missing_methods; die __PACKAGE__ . ' forgot to implement ' . join ', ', @missing if @missing; sub new { my ( $class ) = shift; my $self = {}; bless $self, $class; return $self; } sub iface1_method { my ( $self, $arg ) = @_; print"\nclass->iface1_method : called with $arg\n\n"; return $self; } sub iface2_method { my ( $self, $arg ) = @_; print"\nclass->iface2_method : called with $arg\n\n"; return $self; } #################################### # bootstrap #################################### #!/ms/dist/perl5/bin/perl5.8 use Data::Dumper; use class; my $c = new class; $c->iface1_method("passed in to 1"); $c->iface2_method("passed in to 2"); print "Dump of object: class:\n",Dumper $c; print "\nEND \n\n";