============== Foo.pm ============== package Foo; use strict; require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw( foo ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our $VERSION = '0.01'; sub foo { die "This is being called from Foo\n"; } 1; __END__ ============== Bar.pm ============== package Bar; use strict; use Foo qw(foo); our $VERSION = '0.01'; sub new { my ($class) = @_; my $self = []; bless($self, $class); } sub bar { my ($self) = shift; foo(); } 1; __END__ ============== Baz.pl ============== use strict; use warnings; use Test::MockModule; use Bar; { my $mock = Test::MockModule->new('Foo'); $mock->mock('foo', sub {print "Successfully mocked!\n";}); my $bar = Bar->new(); $bar->bar(); }