http://qs321.pair.com?node_id=792092


in reply to A working strategy to handle AUTOLOAD, can(), and (multiple) inheritance without touching UNIVERSAL?

If I want to have can awareness I would have to overload can.

You can also predeclare the subs you want to AUTOLOAD.

That can be tricky business.

Not really. If your AUTOLOAD has some logic to determine whether it should generate a subroutine, you can factor that logic into a subroutine shared between AUTOLOAD and an overridden can.

You don't even have to go through gyrations in can to return a reference. Perl 5 autovivifies subroutines if you take references to them in the appropriate way. Of course, you can also factor out the code which installs the reference and share it between can and AUTOLOAD.