did you check out?
http://search.cpan.org/search?dist=HTML-Template

this might do most of what you need, and handle some things
you haven't thought of yet.

cliff rayman
genwax.com

Steven Champeon wrote:

> Hi, gang. I'm working on my first serious mod_perl app, and have a few
> questions regarding efficiency -- basically looking for traps I may not
> have internalized after reading the mod_perl_traps page and so forth.
>
> I'm developing a site that will use MySQL on the backend to store some
> info related to goofy timewasting projects (e.g., name, url, contributor,
> date last updated, description, etc.) The idea is that there really needs
> to be a site where I can list all my goofy timewasting projects, and I
> want other people to submit their stuff, too. Sort of a freshmeat for the
> random non-commercial stuff that abounds on the 'Net, but which seems to
> be neglected in this weblog age, or doesn't get much notice unless it's an
> Open Source [tm] project with millions of contributors. :)
>
> Anyway. I have been designing the templates for each class of page on the
> site (main project list, individual project detail, admin forms, and so
> forth). I want to populate each template with data from the db.  I don't
> particularly want to use EmbPerl; I'd rather read the templates at init
> time and parse in the db data when the page is to be returned.  Are there
> any traps I should be aware of? I only have four or five relatively small
> templates, so memory consumption shouldn't be a big deal. From what I
> understand from reading the Guide, these vars will likely be shared,
> anyway, right, if I make the vars global and populate them at startup?
>
> I figure I'll put the actual perl modules in lib/perl/, and put the
> templates I'm going to use in directories under docroot that correspond
> to the handler I've defined, just for sanity's sake. So,
>
> <Location /hello>
>  SetHandler perl-script
>  PerlHandler Apache::Hello
> </Location>
>
> would use templates found in $docroot/hello, and so on. But the actual
> templates would be loaded at httpd init time, and kept around, then
> I'll perform substitutions on them based on user input or database info.
>
> I know about using /o to compile a regex. The embedded tokens in the
> templates won't change, so this will probably work fine, right?
>
> (e.g.:
>
>  <!--( $variable )-->
>
> can be replaced by the variable's value on the fly, without hitting
> the disk to open the template file:
>
>  my $variable = "something I got from a form or db";
>  my @lines = split($GLOBAL_VAR_CONTAINING_TEMPLATE_GUTS);
>  while(@lines) {
>    s/<!--( $variable )-->/$variable/o;
>    print;
>  }
>
> I know to use persistent db connections and pre-load DBI. I know to
> tweak Max* to maximize performance. I'm just wondering if there's any
> other obvious traps that come to mind. Thanks in advance.
>
> Steve

Reply via email to