package Package; { sub perform { return $_[0] + $_[1]; } } package main; { use Mock::Sub; use Test::More; tests(); my $m = Mock::Sub->new; my $changed = $m->mock('Package::perform'); $changed->return_value($_[0] - $_[1]); tests(); done_testing(); sub tests { is Package::perform(5, 5), 10, "5 + 5 = 10"; } }