Marcello has asked for the wisdom of the Perl Monks concerning the following question:
The output is: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();
So the fatal error triggered when calling a non-existing method is not caught.WARNING: This will trigger $SIG{__WARN__} at test.pl line 20. Can't locate object method "NonExistingFunction" via package "Test" at + test.pl line 26.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Catching warnings
by friedo (Prior) on Dec 13, 2005 at 18:45 UTC | |
by Marcello (Hermit) on Dec 13, 2005 at 18:50 UTC |