Matthew Hodgson wrote:
The other problem is that "do" will compile the script every time, even if it has been run before in that same process. Slow.On Fri, 15 Nov 2002, Josh Chamas wrote:Matthew Hodgson wrote:Hi, I have a script which executes under Apache::Registry and resides in /perl/blah.pl. However, it only generates a fragment of a page, and is normally embedded into an html template using SSI with something like: <!--#perl sub="Apache::Include" arg="/perl/blah.pl" --> I am very aware that this would be better implemented as a raw perl module used from apache's startup.pl (and then embedded using something like <!--#perl sub="Blah" -->) - but practically this isn't an option right now.How about just executing this file like this: do "$path_to/perl/blah.pl";I guess that just as long as the script is never actually executed under Apache::Registry, and if the only place it's ever do'd from is the plain library, then this is the best solution. :) Presumably if I needed to execute blah.pl from many different libraries as well as actually embed it using <!--#perl sub="Apache::Include" -->, this wouldn't be so great as each instance of it would be compiled separately as part of that particular block of code, thus bloating the apache process horribly.
You might want to look at how Apache::SSI does it. You can copy the include handling code from there. Otherwise, I would suggest copying some code from Apache::RegistryNG to compile it into a subroutine.
- Perrin