in reply to Re: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.
in thread Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.

Hi, I have tried moving *AUTOLOAD = \&BASE_CLASS::AUTOLOAD; to BEGIN {} block, it's not working.
Note that i am having perl 5.34.
using require for that particular .pl file seems working for me, but i have to modify all such instances for the same.
i am looking for better solution.
Thank you

  • Comment on Re^2: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.

Replies are listed 'Best First'.
Re^3: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.
by LanX (Saint) on Sep 27, 2021 at 17:20 UTC

      Hi, my code looks below, please ignore previous comment

      ##script homepage.pl #this script has been located in cgi folder where + it also has SUBS/APP folder package homepage; our ($AUTOLOAD_DEFINED); # This isn't necessary, but without it you ge +t a warning when perl uses UNIVERSAL::AUTOLOAD if (!$AUTOLOAD_DEFINED) # (from lib.pl): "Use of inherited AUTOLOAD f +or non-method...". (search for that warning { # text in 'perldoc perldiag' for more info. *AUTOLOAD = \&APP::AUTOLOAD; $AUTOLOAD_DEFINED = 1; } # # #below is the non-method called from the perl file (getStatuses.pl) lo +cated at cgi/SUBS/APP/Statues @Statuses = &APP::Statuses::getStatuses({IsResolvedFlag =>1}); #here + is is failing to autoload the script getStatuses.pl.

      In other script (lib.pl) where AUTOLOAD function is defined which would control the autoloading part, it also has below line outside of AUTOLOAD function
      # use APP package's AUTOLOAD for all packages that don't have their ow +n *UNIVERSAL::AUTOLOAD = \&APP::AUTOLOAD;

      Note : I cant see anywhere autoLoader module has been used instead AUTOLOAD function has been written.
      I hope this helps you to understand the scenario.
      Thank you

        Sorry I don't know how to reproduce an example with this information ... maybe someone else.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Re^3: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.
by LanX (Saint) on Sep 27, 2021 at 15:08 UTC
    > but i have to modify all such instances for the same

    same with  *AUTOLOAD = \&BASE_CLASS::AUTOLOAD;

    (shrug) !

    I know many dirty workarounds° in Perl but I doubt what you want is possible or even desirable.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    °) well as always with Perl ... provided the base class is directly used one could try a source filter to inject sub AUTOLOAD in the importing file. But I wanna be damned before showing how...

      FWIW: an even less stable hack would be to write something like an 'INIT {}' or 'CHECK{ }' block to indentify all defined packages/classes after compilation which inherit from the BASE_CLASS:: ( see ->isa in UNIVERSAL )

      all those packages could then have a new AUTOLOAD added via eval.

      this will not work in all cases because those timing issues in Perl are highly flexible:

      • a sub could have been called before compilation finished.
      • a class could be defined dynamically afterwards at runtime
      • ...

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery