in reply to Switch off warning for UNIVERSAL::AUTOLOAD

If you're not using 5.6 (which has controllable warnings), try this:
BEGIN { $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /inherited AUTOLOAD/; }; }
Or stop calling autoloaded class methods for classes where you've not installed an AUTOLOAD handler.

In other words, if A "isa" B, don't create just B::AUTOLOAD: also install A::AUTOLOAD. That's all this is complaining about... it had to follow the @ISA for a class method or an ordinary subroutine (and that's guaranteed to break in the future... hence the deprecated part of the message).

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
RE: Re: Switch off warning for UNIVERSAL::AUTOLOAD
by Yaakov (Novice) on Aug 08, 2000 at 22:05 UTC
    Thanks to you help, I finished now version 0.1 of the "EveryThing" module: After

    use EveryThing;

    Perl pretends to have loaded all routines from a data base (a hash tied to a DB_File) and to initialized all packages.

    In reality, it waits until a routine is first called and loads it then. Also, package initialisation is delayed until the package is actually used.

    Of course, the subtle details between OOP and AUTOLOADING require some attention but I believe that I got it (mostly) right. Maybe I post the module to this site when I have added some documentation and utilities...

    Now, I am scared because you write: <quote> and that's guaranteed to break in the future... </quote> This means my module will not work in the future: It relies on the fact that EveryThing will call UNIVERSAL::AUTOLOAD in case it's not yet in the system.

    In fact, an older version of the module did some guesswork what modules a piece of code might want to use and initialized AUTOLOAD for all these packages. But this guesswork required some assistance from the programmer in cases like calling a constructor of a variable class. Also, the first code piece called needed some explicit initialisation.

    I completely agree that AUTOLOADing via @ISA is not the RightThing. But UNIVERSAL::AUTOLOAD is different because it has an additional useful semantics.

    Thanks again for you quick help.

    Yaakov

RE: Re: Switch off warning for UNIVERSAL::AUTOLOAD
by Yaakov (Novice) on Aug 08, 2000 at 18:28 UTC
    Thank you very much for your answers.

    Yaakov