Re: HTML::Template bug report: Problems using cache

Sam Tregar <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
On Tue, 29 Nov 2005, Jozef Kosoru wrote:

> Since there wasn't any new release for more than one year I would also like
> to ask you whether this package is still maintanted.

It's still maintained, although I'm too busy to spend a lot of time on
it right now.  Maybe next year...

> Regarding this bug. Could you help me somehow, please? I've tried to fix
> it myself, but the code is a bit too complex. Thank you.

Hmmm, alright, let's see.

>    my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1);
>    my $rTmpl2 = HTML::Template->new(filename => $htmlTemplate, cache => 1);

Ok, that won't work.  The cache is going to hand you back two
references to the same object.  Try this instead:

   use Storable qw(dclone);
   my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1);
   my $rTmpl2 = dclone($rTmpl2);

Or, possibly faster:

   use Clone qw(clone);
   my $rTmpl1 = HTML::Template->new(filename => $htmlTemplate, cache => 1);
   my $rTmpl2 = clone($rTmpl2);

-sam


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.