Suppress warning

Discussion in 'Perl Misc' started by Ian Wilson, Apr 20, 2007.

  1. Ian Wilson

    Ian Wilson Guest

    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?
     
    Ian Wilson, Apr 20, 2007
    #1
    1. Advertising

  2. Ian Wilson

    Paul Lalli Guest

    On Apr 20, 10:53 am, Ian Wilson <> 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';".
     
    Paul Lalli, Apr 20, 2007
    #2
    1. Advertising

  3. Ian Wilson

    -berlin.de Guest

    Ian Wilson <> wrote in comp.lang.perl.misc:
    > 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.


    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
     
    -berlin.de, Apr 23, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christian Seberino
    Replies:
    0
    Views:
    356
    Christian Seberino
    Oct 21, 2003
  2. Ian Bicking
    Replies:
    0
    Views:
    393
    Ian Bicking
    Oct 22, 2003
  3. Replies:
    3
    Views:
    331
    Malcolm McLean
    Nov 28, 2007
  4. Antoninus Twink

    Re: best way to suppress "unused" warning?

    Antoninus Twink, Apr 25, 2008, in forum: C Programming
    Replies:
    6
    Views:
    350
    Ian Collins
    Apr 29, 2008
  5. Replies:
    0
    Views:
    478
Loading...

Share This Page