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 #### ## both apps $oosub = OO::SubModule->new({ debug_cb => sub { my $self = shift; my ($str) = @_; goto &{_debug}; }, }); ## Any occurrence of $self->_debug("booya") within OO::SubModule really does _debug("booya") of the main app, this way ## Without getting in the call stack, right?