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


in reply to Strange code execution with 'AUTOLOAD'

DESTROY is the destructor for the class. If you use AUTOLOAD but not DESTROY, you will get the above error message, because AUTOLOAD is called for the DESTROY method (because AUTOLOAD catches all undefined method calls on the object), and you do not have a DESTROY method to call.

Since you have Object Oriented Perl, I suggest you look at page 112, at the section "Destructors and autoloading". It explains the situation far better than I can, and offers a solution (actually, two).

For those who don't have the book :), the best solution is to define an empty DESTROY method in your class:

sub DESTROY { }
The existence of this method will prevent AUTOLOAD from being called on object destruction.