sub drive_type { my ( $self, $drive ) = @_; if ($drive) { unless ( $drive =~ /^(?:fwd|rwd|4wd)$/ ) { die "$drive not a valid drive type. Use fwd, rwd or 4wd\n"; } $self->{'drive'} = $drive; } return $self->{'drive'}; } sub body_type { my ( $self, $body ) = @_; if ($body) { unless ( $body =~ /^(?:sedan|wagon|coupe|hatch)$/ ) { die "$body not a valid body type. Use sedan, wagon, coupe or hatch\n"; } $self->{'body'} = $body; } return $self->{'body'}; } sub engine_cap { my ( $self, $cap ) = @_; if ($cap) { $self->{'engine_cap'} = $cap; } return $self->{'engine_cap'}; }