2010.05.31 [JBR] - (is there any convention for dating wiki entries?) I often use tcl [subst] to generate code for my own or one tcl's mini languages. Here is a little template helper that I wrote last week. I like the code because is reuses tcl's foreach and allows substitution of any variables in the current scope, but I'm dissatisfied with the need and technique to awkwardly generate uniq string accumulator variable names to support recursion. Any ideas for improvement would be appreciated. ---- package require Tcl 8.5 proc template:foreach { args } { incr ::template:level set reply [uplevel [subst { set _${::template:level} {} foreach {*}[lrange $args 0 end-1] { append _${::template:level} \[subst {[lindex $args end]}] } set _${::template:level} }]] incr {::template:level} -1 set reply } interp alias {} : {} template:foreach puts [: x { 1 2 3 } { Row $x [: y { a b c } { Column $y }] }] Produces: Row 1 Column a Column b Column c Row 2 Column a Column b Column c Row 3 Column a Column b Column c <>Enter Category Here