I'm working on a template-reading module and I have a
question.

Are you sure you need to do that ?
Templating modules are already extremely over-implemented and you should be able to find a suitable one on CPAN.


Here are some articles about the topic:

http://twiki.med.yale.edu/twiki2/bin/view/CGIapp/CompareTemplates
http://perl.apache.org/docs/tutorials/tmpl/comparison/comparison.html

While they a concerned mainly with using templating engines for CGI applications, they give a good overview of general purpose templating solutions.

I'm using a regex to pluck out the
references to data and replace them with the data
itself, and the template file can be very long.

If all you want to do is replace references to data with the data (strings ?),
you should take a look at HTML::Template (which in spite of its name can be used for any kind of text, not just HTML)


Using this module, you can read (and parse) your template once, after which it will be in main memory in a very efficient format.
You can then reuse it as often as you want.


The only situation where HTML::Template might be a little inconvenient is when you do not know the names of the parameters (the references to your data) beforehand.
Do you?



Seriously, try to use a CPAN templating module,


Thilo



Reply via email to