It seems that every time I go back to this, I get bitten again, so finally I'd like to see if there's a better way.
I frequently have loops more or less like the following: [% FOREACH book = books %] [% SET biblio = book.biblio IF book.biblio %] [% biblio = biblio | some_filter %] ... [%# something that displays my book %] [% END %] Then, when I run into a record with no biblio, I get the previous one repeated because the "biblio" var doesn't get cleared at the end of the loop. So at the end of my loop, I have to remember to undef all the variables I used within. This is annoying, and contrary to what I expect in Perl. I assume, but am not sure, that this is what the Directives chapter is referring to by "under normal operation, the loop variable remains in scope after the FOREACH loop has ended". If so, perhaps it could be made more clear. If I'm just missing what's right in front of my eyes, I'd be grateful for a pointer. Either way, is there a way of doing this that's more natural than undef'ing each variable individually before the loop ends? Thanks. Jesse Sheidlower P.S. I do note that there are times when I _do_ set a variable _outside_ the loop that I then modify inside the loop--a variable controlling the color of alternating rows, for example--and I don't want this to be reset. Basically if I declare a variable inside the loop, I only want it scoped within that loop, like normal in Perl. _______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates
