#! /usr/bin/env perl use 5.020; use strict; use warnings; package DB::Base { use Moo; has name => (is => 'ro'); sub option { my ( $self, $key ) = @_; die('missing key') unless ($key); die( 'missing option `' . $key . '`' ) unless $self->can($key); return $self->$key; } } package DB::Customer { use Moo; extends 'DB::Base'; has type => (is => 'ro', default => 'customer'); has currency => (is => 'ro', default => 'Euro'); ...; } package main; my $customer1 = DB::Customer->new(name => 'id_customer 1'); __END__;