package OO::SubModule; sub new { my ($class, $args) = @_; my $self = { ( defined $args ? %$args : () ) }; bless($self, $class); ## Some boilerplate debug callback that we can override during construction $self->{debug_cb} //= sub { my $self = shift; carp("DEBUG ".join(", ", map { defined $_ ? $_ : "undef" } @_)); }; return $self; } sub _debug { my $self = $_[0]; goto &{$self->{debug_cb}}; } ## You can say $self->_debug("booya") to do $self->{debug_cb}->("booya") without it ending up in the call stack