{ package RaceHorse;
our @ISA = qw(Horse);
## extend parent constructor:
sub named {
my $self = shift->SUPER::named(@_);
$self->{$_} = 0 for qw(wins places shows losses);
$self;
}
sub won { shift->{wins}++; }
sub placed { shift->{places}++; }
sub showed { shift->{shows}++; }
sub lost { shift->{losses}++; }
sub standings {
my $self = shift;
join ", ", map "$self->{$_} $_", qw(wins places shows losses);
}
}
my $racer = RaceHorse->named("Billy Boy");
# record the outcomes: 3 wins, 1 show, 1 loss
$racer->won;
$racer->won;
$racer->won;
$racer->showed;
$racer->lost;
print $racer->name, " has standings of: ", $racer->standings, ".\n";