#!perl
# in a file: Inherit.pm
use strict;
use warnings;
package Inherit;
use base qw/BaseObj/; # It can't be that easy, can it?
use fields qw/town team/;
# new - construct an Inherit object
sub new {
my ($self) = shift;
unless ( ref($self) ) {
$self = $self->SUPER::new($self);
}
$self->{town} = "San Diego";
$self->{team} = "Padres";
return $self;
}
# go - going home but with the home team too!
# polymorphic behaviour
sub go {
my ($self) = @_;
return $self->SUPER::go . $self->where;
}
# where - show where this team is home to
sub where {
my ($self) = @_;
return $self->{town} . " is home to the " . $self->{team} . "\n";
}
1; # enables Perl to know it loaded properly