package Foo; # must use '\' to create the reference, and since it's a # reference not an invocation, we can't specify arguments # here. (see the .pl file at the end) *do_something = \&make_do_something; sub make_do_something { # make_do_something is the method called, hence the # object reference will be on *this* @_, not the # one below. my ($self, $name) = @_; #### return sub { if ( $name ne 'foo' ) { print "Not foo\n"; $self->SUPER::do_something(); } print "Foo $name!!!\n"; return 1; } } 1; #File: Bar.pm package Bar; use base 'Foo'; *do_something = \&Foo::make_do_something; sub new { bless {}, shift(); } 1; #!/usr/local/bin/perl use lib '.'; use Foo; use Bar; $b = new Bar(); # just calling do_something won't cause the subroutine # returned to execute; we've got to do that ourselves. my $sub = $b->do_something('foo'); # supply args here, not above. store the subroutine ref $sub->(); # dereference it to run it