To make full (and "correct") use of OO, the properties need to be encapsulated.
use warnings;
use strict;
package CfgBase {
use Moo;
use namespace::clean;
has on_error => (is => 'ro', default => "exit");
has output_type => (is => 'ro', default => "text");
sub dump {
my $self = shift;
print ref($self),":\n";
print " $_: ",$self->$_,"\n" for qw/ on_error output_type /;
}
}
package CfgChild {
use Moo;
use namespace::clean;
extends 'CfgBase';
has '+on_error' => (default => "warn");
}
CfgBase->new->dump;
CfgChild->new->dump;