in reply to A caller() by any other name

I think the perlish syntax you're looking for is a closure/code reference. That is, instead of passing in a full object or type, you pass in a CODE reference that does whatever you need it to do. That code reference, being a closure, would have access to the calling object to do work with it, but any work done on the calling object would still live inside the calling object. That is, the code dealing with $foo would live in Foo.pm, not in Bar.pm.

package Foo; sub do_it { my $self = shift; my $do_it_to = shift; $do_it_to->handler(sub { $self->logger(@_) }); } # and other stuff, like sub logger. package Bar; sub handler { my $self = shift; my $callback = shift; for ($self->get_all_items()) { $callback->($_); } }
Something like that.

If you find yourself needing more than one callback in a single function (such as handler above), you may be better off defining an API that the function needs, and requiring that an object that handles that API be passed in. Otherwise the function call will get ugly.