in reply to Re^8: 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.
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
*) added, otherwise the output is littered with all objects with undefined DESTROY methods triggering AUTOLOAD.
|
|---|