package Test; use strict; use warnings; sub new { my $this = shift; my $class = ref($this) || $this; my $self = {}; bless($self, $class); $SIG{'__WARN__'} = sub { print 'WARNING: '.$_[0]; }; return $self; } sub A { my $self = shift; warn 'This will trigger $SIG{__WARN__}'; } sub B { my $self = shift; $self->NonExistingFunction(); } my $test = Test->new(); $test->A(); $test->B();