Suppress warning

I

Ian Wilson

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?
 
P

Paul Lalli

When I run the code below I get an unwanted warning and the expected result.

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';".
 
A

anno4000

Ian Wilson said:
When I run the code below I get an unwanted warning and the expected result.

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.

The warning can be suppressed by excluding *two* warning categories:

no warnings qw( syntax deprecated);

I have not seen a case like that before.

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top