> I'm using TT 2.05 on AIX 4.3.3. > I have a problem with conflicting names. I use something like the > following: > > ---- > [% > i.array=[ 1, 4, 7, ] > %] > xxx[% i.array %]yyy[% i.array.1 %]zzz > [%- FOREACH i=[ -10 .. 10 ] -%] > [%- END -%] > [% > i.array=[ 1, 4, 7, ] > %] > xxx[% i.array %]yyy[% i.array.1 %]zzz > ---- > > After the FOREACH-loop, the array i.array is no longer > defined. Surely, I > can use other names, but they would be less intuitive in my > real examples > and I would have to change quite a lot of them. > Is there a way to solve this naming conflict. Is there a way > to undefine > the variable i after the loop only with a TT-directive (no perl code)?
There isn't a localization command that I know of but you can use BLOCK to your advantage for these sorts of issues. INCLUDE makes a copy of the Stash and so protects you from changes made inside blocks. (To an extent, anyway). I know that isn't what you are asking for but it might help. --mark [% i = 3 %] [% INCLUDE i +%] i = [% i %] [% BLOCK i %] inside i=[% FOREACH i = [ 10..20 ] %][% i %] [% END +%] [% END %]
