I have a strange thing happening that I would like to understand.
Here is the code in it's essentials:
So here we have a package that keeps an instance of a class Y in a "static" variable.package X; use strict; use Y; my $y = Y->new; 1;
Here now the implementation of Y:
As you can see it's just an (empty) Moose-based class that provides an (in this case even empty) destructor.package Y; use Moose; sub DEMOLISH {} 1;
Now I have a little driver script:
All this trivial stuff now results in this warning when the script exits:use strict; use X; print "done\n";
(in cleanup) Can't call method "default" on an undefined value at (eval 36) line 7 during global destruction.
So evidently during the global destruction phase (that I have never fully understood) something gets cleaned up in a way that seems to confuse Moose or what is happening here?
The problem is not just this warning but the fact that the destructor (code in DEMOLISH) then never gets run so this means that I cannot rely on destructors to clean up resources when the Moose-instance is held in a static variable and gets garbage collected only during global destruction...
Regardless of whether or not using destructors in such a way is good or bad style - could someone explain what exactly is causing this problem?
Many thanks!
PS: I am running 5.10 on Linux with Moose 0.62
In reply to global destruction and Moose by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |