in reply to removing someone elses AUTOLOAD
Theoretically, if you called $obj->option('some_random_option'), option needs to handle it anyway. So I don't see much of a problem with that tactic. It means there is only a single point at which one needs to validate the option is valid.
It sounds like option isn't validating what is passed in - that's a seperate issue, and has absolutely nothing to do with AUTOLOAD.
What does have something to do with AUTOLOAD is the fact that it's not dealing with DESTROY. The simplest way to deal with that is to create a DESTROY method:
Once you've done this, DESTROYs won't be dispatched to AUTOLOAD at all.{ package Foo::Bar; sub DESTROY {} }
I don't think AUTOLOADs are necessarily bad, but I do see that they give a lot of temptation to develop badly. Right up there with eval STRING and goto. (That AUTOLOAD is often paired with goto is another issue.) Used appropriately, you can really take advantage of the dynamic nature of perl and provide syntactic sugar that you just can't do in any many other languages.
|
|---|