use warnings; use strict; { # begin of Car class package Car; sub new { my $class = shift; my $self = {}; bless $self, $class; $self->_init(@_); return $self; } { my @_init_data = qw(name drive body engine_cap); sub _init { my ( $self, $description ) = @_; my %data; @data{@_init_data} = @$description{@_init_data}; %$self = %data; } } sub car_name { my $self = shift; return $self->{name}; }