# You could load the hash from a database table, or just call the database for # each car. I'm just hardcoding for this example: my %car_models = ( Corolla => { drive=>'fwd', body=>'hatch', engine_capacity=>1798 }, Tercel => { drive=>'fwd', ... } ); while () { chomp; my $car = Car->new(); my $model_attributes = $car_models{$_}; $car->drive_type($model_attributes->{drive}); $car->body_type($model_attributes->{body}); $car->engine_cap($model_attributes->{engine_capacity}); ... } #### sub load_defaults_for_model { my $self=shift; my $model_attributes = $car_models{$self->{Model}}; $self->drive_type($model_attributes->{drive}); $self->body_type($model_attributes->{body}); $self->engine_cap($model_attributes->{engine_capacity}); } sub new { my ($class, $model) = @_; my $new_obj = { .... build your object .... }; bless $new_obj, $class; if (defined $model) { $new_obj->{model} = $model; $new_obj->load_defaults_for_model(); } return $new_obj; }