%ALLOWED_TABLES = map {$_ => 1} qw(company financialDiary); sub add_data { my ( $self, $table, $data ) = @_; die "bad table!" unless $ALLOWED_TABLES{$table}; my $data = $self->_generic_insert( $data, $table ); $self->{ _dbh }->commit if ! $self->{ _error }; return $data; }