If BEGIN is not called for each request then how the come END is?
I mean going by the logic that the BEGIN is only executed once when the script is loaded into memory, I would assume that the END is also only executed once when it leaves memory
i.e the interpreter ends not the request.
that'll teach me to assume eh.
regarding your problem I think you are probably right perls own garbage collection will hopefully save you the bother.
....
This was annoying me, so google yielded this understanding mod_perl environments | [reply] |
If BEGIN is not called for each request then how the come END is?
I think the reason is, that Apache::Registry is meant to make it easy to run CGI scripts as mod_perl scripts. Since END blocks in CGI scripts are run after each request, they also run after each request when using Apache::Registry. I don't like it either, but apparantly, that's how it is.
As for BEGIN blocks: if you really want to run them at the right time, you'd have to remove all the loaded code and variables from the interpreter before handling the request (and then reload all the code) - it would probably make Apache::Registry scripts almost as slow as normal CGI scripts.
| [reply] |
Did you mis-read? I have a BOOT: section (an XS keyword), not a BEGIN sub.
END is called for each request if the module was loaded by the Apache child process. If it is preloaded by the server process (e.g. PerlModule line in the httpd.conf file) then the END is only run once when the server shuts down. This is fine, except that it isn't possible for a source filter module, which, as I said, is necessarily loaded by the child when loading the script.
Unless, of course, you have the server pre-load the script (?)
Anyway, I wanted a more "natural" solution that doesn't require the user to have loaded the script/module at some particular time.
| [reply] |
Having an object to DESTROY seems like a neat idea, so I'll try that.
Thanks | [reply] |