;# Using eval on a single command: set cmd {puts "Evaluating a puts"} puts "CMD IS: $cmd" eval $cmd ;# Using eval to define a proc if {[string match [info procs tempFileName] ""] } { puts "defining tempFileName for this invocation" set tmpFileNum 0; set cmd "proc tempFileName {}" lappend cmd "global tmpFileNum;" lappend cmd "incr tmpFileNum;" lappend cmd " return \"/tmp/TMP.[pid].$tmpFileNum\"; " eval $cmd } puts "The body of tempFileName is: [info body tempFileName]" puts "tmpFileName returns: [tempFileName]" puts "tmpFileName returns: [tempFileName]"