in reply to DESTROY and AUTOLOAD in 5.20.1

G'day szabgab,

[I'm assuming a copy/paste typo: s/DESTROY/sub DESTROY/]

My reading of perlobj - Destructors, suggests that &DESTROY is only invoked if it has been defined (for instance, there's no default &UNIVERSAL::DESTROY). In particular, the second paragraph:

"If you want to do something when the object is destroyed, you can define a DESTROY method in your class. This method will always be called by Perl at the appropriate time, unless the method is empty."

So, if &DESTROY isn't called, &AUTOLOAD won't come into play.

-- Ken

Replies are listed 'Best First'.
Re^2: DESTROY and AUTOLOAD in 5.20.1
by szabgab (Priest) on Apr 25, 2015 at 07:08 UTC
    sub or no sub, that does not matter for these functions, but I should be more consistent in my example. I think the documentation you linked to says that AUTOLOAD will be called if it exists and DESTROY does not and this was the old behavior.