![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
Pkg::END{} executes 2+ times, on how many times use Pkg; or do Pkg.pm;by petr999 (Acolyte) |
on Jan 22, 2010 at 16:35 UTC ( [id://818994]=perlquestion: print w/replies, xml ) | Need Help?? |
petr999 has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have the END{} block on some module. It is use()d by some script, to 'todo' script. The 'preload' script does the do() on it. Both execute the code in the context of the package main; The 'preload' script fork()s then and the compiled module's machine code is shared among the forks. The problem is: if I put the 'use module;' or 'do "module.pm";' on the 'preload' script no matter if it is before the do() of the todo.pl or after, the END{} of the module gets to be executed twice. I suppose there should be the built-in variable that keeps the used modules each time they use to be loaded. This is not the %INC because the module.pm is the key of that hash. There is certainly a condition on the rest of the code that influenced the code to behave like that, I could not reproduce all of that at the moment being with the vanilla plain module, todo and preload files to put them here as a simple sample of the code. Although the reproduceable code itself is a no secret at all. I am sure it should be obvious for some kind Monk to know such a stuff. ;-) Thank you.
Peter Vereshagin peter@vereshagin.org http://vereshagin.org
Back to
Seekers of Perl Wisdom
|
|