On Tue, 11 Jun 2002, Sam Tregar wrote:
> On Tue, 11 Jun 2002, Nico Erfurth wrote:
>
> > It changes the way arrays/loops are handled.
> > 1.) If you pass in a array-reference, it will be not dereferenced anymore
> > I did this, so i can use a small Wrapper-class, which allows me to
> > tie a database-statement to an array, and returning the results row by
> > row, so i don't need to waste memory inside of mod_perl(Reading all
> > results at once).
>
> This is incorrect. People like to do:
>
> my @loop = ( { row => 'foo' }, { row => 'bar'} );
> $template->param(LOOP_ONE => \@loop);
> @loop = ( { row => 'bif' }, { row => 'bop'} );
> $template->param(LOOP_TWO => \@loop);
>
> If you don't copy out the contents of @loop in the first param() call then
> you'll end up referencing the same array twice. This was actually a bug
> fixed in the early development of HTML::Template.
I thought about this, and i'm wondering how much ppl realy use it in this
way.
IMHO it should be a "Don't try this, it will break", instead introducing
this copy-"workaround".
But i think i will use this patch only for my private-version, because i
don't use such constructs ;)
> > 2.) HTML::Template::Loop::output was changed, so it appends to a given
> > scalar-reference(the one from HTML::Template::output), this saves much
> > memory if you have a big loop and combine it with the print_to-option.
>
> That sounds interesting, but have done tests to confirm that it helps? I
> suspect that you'd have to choose a truely pathalogical data-set to see
> any improvement.
I have to print out much lines in a big loop, and these two patches helped
me to decrease the memusage from 50MB per instance to 5MB, but i haven`t
checked both things seperatly.
At least, this patch not just helps to decrease memory-usage, it also
makes it possible to put out the loop while it is processed.
>
> > I send this patch to Sam Tregar weeks ago, and i never answered,
(Should be He, not I ;)))
> > but maybe
> > someone here thinks that it's worth to have a look at it, because AFAIK
> > many ppl use mod_perl+HTML::Template (i do it myself) ;)
>
> Sorry about that! I must have let it fall through the cracks. Did you
> send it directly to me or to the HTML::Tempate mailing-list? Things sent
5-6 Weeks ago, i sent it directly to you, and my Mailbox shows, that i
send a copy to the mailinglist on Mar 14.
> to the mailing-list tend to stay on my radar slightly longer.
ciao,
Nico
P.S. HTML::Template is a great module, it just ate too much memory in my
case ;)