http://www.perlmonks.org?node_id=946566

PerlOnTheWay has asked for the wisdom of the Perl Monks concerning the following question:

try.t:
#! /usr/bin/perl use strict; use warnings; use Test::MockModule; my $father = Test::MockModule->new('Father'); $father->mock(alert => sub { print 'replaced by try' . $/; }); do 'Son.pm';
Father.pm
package Father; sub alert { print 'father' . $/; } 1
Son.pm:
package Son; use base Father; sub new { bless {}, Son; *{'Father::alert'} = sub { print 'son' . $/; }; } Son->new->alert();

When I run try.t,nothing is outputed

But if I delete the typeglob operation in Son.pm, I can get something outputed

why?