Re: Suppress warning
- From: Paul Lalli <mritty@xxxxxxxxx>
- Date: 20 Apr 2007 13:40:56 -0700
On Apr 20, 10:53 am, Ian Wilson <scoblo...@xxxxxxxxxxxxx> wrote:
When I run the code below I get an unwanted warning and the expected result.
> soapclientauto.pl
Use of inherited AUTOLOAD for non-method main::c2f() is deprecated at
soapclientauto.pl line 11.
41.1C = 105.98F.
------------------------------------------------------
#!perl
use strict;
use warnings;
use SOAP::Lite +autodispatch =>
uri => 'http://www.example.com/Temperature',
proxy => 'http://localhost/cgi-bin/soapservice.pl';
{
no warnings 'deprecated';
print "41.1C = ", c2f(41.1), "F.\n";}
------------------------------------------------------
ActiveState Perl 5.8.8 on XP
The warning arises when I use SOAP::Lite's "autodispatch" feature.
`no warnings;` suppresses the warning but seems overkill.
Is there a way to identify the category of warning so I can suppress it
more selectively?
Is there another way to avoid whatever the warning is warning me of
(which I don't understand) - assuming I don't want to tinker with
SOAP::Lite?
All of Perl's warnings and errors are well documented in `perldoc
perldiag`:
Use of inherited AUTOLOAD for non-method %s() is deprecated
(D deprecated) As an (ahem) accidental feature,
"AUTOLOAD" subroutines are looked up as methods (using
the @ISA hierarchy) even when the subroutines to be
autoloaded were called as plain functions (e.g.
"Foo::bar()"), not as methods (e.g. "Foo->bar()" or
"$obj->bar()").
This bug will be rectified in future by using method
lookup only for methods' "AUTOLOAD"s. However, there is
a significant base of existing code that may be using
the old behavior. So, as an interim step, Perl
currently issues an optional warning when non-methods
use inherited "AUTOLOAD"s.
The simple rule is: Inheritance will not work when
autoloading non-methods. The simple fix for old code
is: In any module that used to depend on inheriting
"AUTOLOAD" for non-methods from a base class named
"BaseClass", execute "*AUTOLOAD = \&BaseClass::AUTOLOAD"
during startup.
In code that currently says "use AutoLoader; @ISA =
qw(AutoLoader);" you should remove AutoLoader from @ISA
and change "use AutoLoader;" to "use AutoLoader
'AUTOLOAD';".
.
- References:
- Suppress warning
- From: Ian Wilson
- Suppress warning
- Prev by Date: Re: perldoc perllocal
- Next by Date: Re: Manipulate fields
- Previous by thread: Suppress warning
- Next by thread: Re: Suppress warning
- Index(es):
Relevant Pages
|