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
$thing
characters in your commandsubst $$thing
are first replaced by the value of$thing
, which isa.b
.Subsequently, the
subst
command is evaluated like this:The above
subst
command replaces$a
with1
, which explains why you get1.b
returned.A reliable way to do multiple variable interpolation is with the
set
command without a second argument. Chain together multipleset
commands to interpolate multiple times.