##
$object->display( { my_code => sub {
my ($hashref) = shift;
foreach (keys %$hashref) {
# more code
}
};
}
);
####
sub display {
my ($self,$args) = @_;
# $args->{'my_code'} has our "custom code"
# here is where we determine which one to use
my $action = $args->{'my_code'} || $self->default_code;
$action->($args);
}