====== proc genrender {template {var OUT}} { set a "append $var \[subst {" set b "}]\n\\1\n" set c [regsub -all -line {$\s*%\s(.*)} $template $b$a ] return $a$c\}\] } set v 3 set mjd "Mark J. Dominus" set mjdweb "http://perl.plover.com/" set L [split "ABCD" ""] set template { You can access variables: $v or environment variables: $env(HOME) You can call functions and evaluate code inline. The list [join $L ", "] has [llength $L] elements. [string repeat = [llength $L]] [join $L ""] [string repeat = [llength $L]] Loop % for {set i 0} { $i < [llength $L] } {incr i} { elem L\[$i\] = [lindex $L $i] % } Append to output % for {set i 0} { $i < [llength $L] } {incr i} { % append OUT " L\[$i\] = " ' [lindex $L $i] ' % } This example is from $mjd at ${mjdweb} % set len [llength $L] The Lord High Chamberlain has gotten $len things for me this year. % set diff [expr { $len - 5 }] % set more "more" % if { $diff == 0 } { % set more "no" % } elseif { $diff < 0 } { % set diff [expr {-$diff}] % set more "fewer" % } That is $diff $more than he gave me last year. } proc render {template} { uplevel 1 [genrender $template] } set OUT "For example" puts [render $template] ====== Produces the following output ====== For example You can access variables: 3 or environment variables: /home/pshook You can call functions and evaluate code inline. The list A, B, C, D has 4 elements. ==== ABCD ==== Loop elem L[0] = A elem L[1] = B elem L[2] = C elem L[3] = D Append to output L[0] = 'A' L[1] = 'B' L[2] = 'C' L[3] = 'D' This example is from Mark J. Dominus at http://perl.plover.com/ The Lord High Chamberlain has gotten 4 things for me this year. That is 1 fewer than he gave me last year. ====== ---- !!!!!! %| [Category Person] |% !!!!!!