On Thu, 8 Jun 2000, Greg Cope wrote:
> > > - the area I was trying to explore was how to read a template (all
> > > HTML with a few <!--TAGS--> in it) and the sub in the new content.
> >
> > Embperl would work fine for that, but it's overkill. Your substitution
> > approach is slower than compiling to perl subs, especially since you have
> > to load the file, but saves lots of memory and is fine for something as
> > simple as this.
>
> Can you enlighten me into the compiling to perl subs ?
It's what Matt was talking about. Your program parses the template,
generates perl code that produces the correct output, evals the code, and
stores the results in a sub reference which you can call whenever you want
that template.
The first time I ever saw this done was with ePerl, but I don't know if
that was really the first. All the embedded perl systems popular around
here (Embperl, Apache::ASP, Mason, etc.) use some variation on this
technique. I think the world's record for most compact implementation
goes to Randal for a small post you can find in the archive here:
http:[EMAIL PROTECTED]
> The file gets loaded once into shared memory - most (stripped) HTML
> files are only a few 10's of K.
>
> Also the file gets loaded once at startup - not during the request
> stage.
You probably won't get much faster than that then, no matter what you do.
Just make sure your regexps are fast (maybe use "study"?) and use
references for passing data.
- Perrin