Let's say I have this code :
set a 1
set a.b a
set thing a.b
puts [subst $$thing]
The answer I would expect on the last line would be "a", but tcl answers 1.b I tried to put \ everywhere before the . but it didn't changed anything.
Is there away to get a from thing variable ?
Tcl does not double evaluate two consecutive dollar signs.
The
$thingcharacters in your commandsubst $$thingare first replaced by the value of$thing, which isa.b.Subsequently, the
substcommand is evaluated like this:The above
substcommand replaces$awith1, which explains why you get1.breturned.A reliable way to do multiple variable interpolation is with the
setcommand without a second argument. Chain together multiplesetcommands to interpolate multiple times.