PerlOnTheWay has asked for the wisdom of the Perl Monks concerning the following question:
try.t:
Father.pm#! /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';
Son.pm:package Father; sub alert { print 'father' . $/; } 1
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?
Back to
Seekers of Perl Wisdom