Step 5: copy all namespace variables into first namespace eval block On unix you can do: $ grep "variable" myfile.tcl| sort | uniq > varlist.txt The varlist file will look something like this, with some dups: # validation routine checks textvariable contents, not key variable arabicarray variable arabicmode variable cellarray variable cellarray variable cellbgcolorA variable cellbgcolorA variable cellbgcolorarray variable cellbgcolorB variable cellchangedcolor variable celldupcolor variable celldupcolor variable cellerrorcolor variable checkcolor variable cols variable cols [list \ variable duplicatesfound variable invalidfound variable kanji1to9 variable kanjiarray variable kanjiarray variable possarray variable rows variable rows variable rows [list \ variable squares variable squares [list \ Final code (same as step 2): namespace eval ::sud { variable rows variable cols variable squares variable arabicmode variable duplicatesfound variable invalidfound variable kanji1to9 variable cellbgcolorA variable cellbgcolorB variable cellerrorcolor variable celldupcolor variable cellchangedcolor variable checkcolor variable arabicarray variable cellarray variable cellbgcolorarray variable kanjiarray variable possarray } Note the vars are somewhat arranged by type and affinity.