Hi all,

I have mod_perl running and I am pre-loading the HTML::Template module (among 
others) when Apache starts up.  I also have a self written Page.pm module with 
the 'print' method and uses the HTML::Template module to do substitutions in a 
template file:

sub print {
         my $self = shift;
         my $template = HTML::Template->new(filename => $self->{'_template_name'},
                                 path => [$self->{'_path_to_templates'}]
         );

        #more perl code...
}

I guess that every time this method is called HTML::Template reads in the the 
template file from disk.  I think this could be faster if the template was in 
memory.  I don't want to hard code the template into Page.pm to avoid the disk 
access, as it would make maintaining the template difficult.  If I preload 
Page.pm and have a BEGIN {} block in it that loads the template file into a 
variable for use within the module, would this BEGIN block get run when the 
module was use'ed, some other time, or not at all?

This is the only method I have thought of so far, will it work?  Does anyone 
have a better idea than this?

Thanks
Will.


Reply via email to