in reply to Re^6: 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.

Try changing

*AUTOLOAD = \&FP::AUTOLOAD;
to
*FP::Introduction::AUTOLOAD = \&FP::AUTOLOAD;
so that it matches the call you are making;

Replies are listed 'Best First'.
Re^8: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.
by LanX (Saint) on Sep 29, 2021 at 10:12 UTC
    Yes. This could explain the issue
    • first version had &UNIVERSAL::AUTOLOAD defined which started to cause warnings after deprication
    • someone started to add *AUTOLOAD=\&MASTER::AUTOLOAD and got rid of most but not all warnings, because he missed some packages.
    • the missed packages which still relied on UNIVERSAL fail now.
    consequence
    • The &UNIVERSAL::AUTOLOAD is cargo cult now and should be deleted°
    • The missed packages must be "repaired"
    (untested, till someone provides a real SSCCE)

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

    °) also because it's a horrible idea causing many problems

      > (untested, till someone provides a real SSCCE)

      here we go to prove my theory

      this works (in a wider sense ;):

      use strict; use warnings; # https://perlmonks.org/?node_id=11137026 package Base; use Data::Dumper; sub AUTOLOAD { our $AUTOLOAD; warn "$AUTOLOAD => ", Dumper \@_; } #*UNIVERSAL::AUTOLOAD = \&AUTOLOAD; package Bla; *AUTOLOAD = \&Base::AUTOLOAD; # aka Bla::AUTOLOAD some_sub(1,2,3); *Foo::AUTOLOAD = \&Base::AUTOLOAD; Foo::some_sub(4,5,6)

      -*- mode: compilation; default-directory: "d:/tmp/pm/" -*- Compilation started at Wed Sep 29 12:33:29 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/universal_autoload.pl Name "Foo::AUTOLOAD" used only once: possible typo at d:/tmp/pm/univer +sal_autoload.pl line 25. Name "Bla::AUTOLOAD" used only once: possible typo at d:/tmp/pm/univer +sal_autoload.pl line 19. Bla::some_sub => $VAR1 = [ 1, 2, 3 ]; Foo::some_sub => $VAR1 = [ 4, 5, 6 ]; Compilation finished at Wed Sep 29 12:33:29

      this horribly fails (please note also all those potential problems caused by UNIVERSAL::AUTOLOAD by triggering with intentionally undefined methods)

      use strict; use warnings; # https://perlmonks.org/?node_id=11137026 package Base; use Data::Dumper; sub AUTOLOAD { our $AUTOLOAD; return if $AUTOLOAD =~ /::DESTROY$/; # ignore destruction * warn "$AUTOLOAD => ", Dumper \@_; } *UNIVERSAL::AUTOLOAD = \&AUTOLOAD; package Bla; *AUTOLOAD = \&Base::AUTOLOAD; # aka Bla::AUTOLOAD some_sub(1,2,3); #*Foo::AUTOLOAD = \&Base::AUTOLOAD; Foo::some_sub(4,5,6)

      -*- mode: compilation; default-directory: "d:/tmp/pm/" -*- Compilation started at Wed Sep 29 12:37:45 C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/universal_autoload.pl Name "UNIVERSAL::AUTOLOAD" used only once: possible typo at d:/tmp/pm/ +universal_autoload.pl line 15. Name "Bla::AUTOLOAD" used only once: possible typo at d:/tmp/pm/univer +sal_autoload.pl line 20. Bla::some_sub => $VAR1 = [ 1, 2, 3 ]; Use of inherited AUTOLOAD for non-method Foo::some_sub() is no longer +allowed at d:/tmp/pm/universal_autoload.pl line 28. Compilation exited abnormally with code 255 at Wed Sep 29 12:37:45

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

      update

      *) added, otherwise the output is littered with all objects with undefined DESTROY methods triggering AUTOLOAD.

Re^8: Use of inherited AUTOLOAD for non-method is no longer allowed with Perl 5.34.
by Anonymous Monk on Sep 29, 2021 at 10:24 UTC

    Hi, Thank you for the suggestion , while it seems to work for the FP package, it is failing with below error for other packages in the code like MRhomepage.
    MRhomepage::MRhomepage__getHomepageType() is no longer allowed.
    Is there any way to make it more generic?
    Thank you

      I'm guessing your file "MRlib.pl" has a mapping from package name to file to require.
      Use that package name list to generate and eval a set of *${packagename}::AUTOLOAD = \&FP::AUTOLOAD; statements.
      That may have to be in a BEGIN block.

      UPDATE: fixed ')' to '}'

        > and eval a set of

        no eval needed with no strict 'refs';

        use strict; use warnings; package FP; sub AUTOLOAD { our $AUTOLOAD; print "hello $AUTOLOAD\n" } my @pkgs =qw/BLA BLUB MyHomepage::Introduction/; for my $PKG (@pkgs) { no strict 'refs'; *{ "${PKG}::AUTOLOAD" } = \&FP::AUTOLOAD } BLA::bla(); MyHomepage::Introduction::intro();

        hello BLA::bla hello MyHomepage::Introduction::intro

        But I already suggested Importing in my first reply ...

        update
        BTW: typo
        *${packagename)::AUTOLOAD = \&FP::AUTOLOAD; ^

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