AUTOLOAD is specific to the package in question. So redefine the package method:
#!/usr/bin/perl
#
{
package autoloading;
sub AUTOLOAD {
print "YEAH ${AUTOLOAD}!\n";
}
sub new {
return bless {}, $_[0];
}
}
$obj = new autoloading();
$obj->foo();
*{autoloading::AUTOLOAD} = sub {};
$obj->bar();
Produces output:
YEAH autoloading::foo!
(no line for the $obj->bar()
call)