我是Perl的新手,所以我不知道它是否可行.
我有兴趣创建一个可以捕获所有调用的模块.
我有兴趣创建一个可以捕获所有调用的模块.
它的用法如下:
$object = new Foo; $object->blah;
解决方法
您可能想要检查
AUTOLOADING
If you call a subroutine that is undefined,you would ordinarily get an immediate,fatal error complaining that the subroutine doesn’t exist. (Likewise for subroutines being used as methods,when the method doesn’t exist in any base class of the class’s package.) However,if an AUTOLOAD subroutine is defined in the package or packages used to locate the original subroutine,then that AUTOLOAD subroutine is called with the arguments that would have been passed to the original subroutine
my $object = new Foo; print $object->blah,"\n"; package Foo; sub new { return bless {},shift } # catch-all function sub AUTOLOAD { return $AUTOLOAD; }
输出Foo :: blah