sub new { my ($class) = @_; my $self = {}; bless $self , $class; my $config = { dbd_user => 'user', dbd_driver => 'mysql', title_text => 'TITLE HERE', database => 'my_database', dbd_port => '3306', style_sheet => 'default.css', dbd_password => 'my_pass', smtp_server => 'mytrusted.mailserver.com', dbd_hostname => '127.0.0.1' }; $self->_debug(1); $self->assign_to_object('conf',$config); # $self->error_to_log(Dumper($self)); return $self; } sub assign_to_object { my ($self,$prefix,$hash) = @_; foreach my $column (keys %{$hash}) { my $method = "$prefix" . "___" . "$column"; $self->$method($hash->{$column}); } }