package main; sub new_foobar_magic { my ($self,@otherargs) = @_; ... } *Foo::Bar::do_magic = \&new_foobar_magic; # or in one swoop: *Foo::Bar::do_magic = sub { my ($self,@otherargs) = @_; ... } # if you want to call the old routine: my $old_foobar_magic = \&Foo::Bar::do_magic; *Foo::Bar::do_magic = sub { my ($self,@otherargs) = @_; ... adjust things or log things ... $old_foobar_magic->($self,@args); };