Re: Difference between $foo and [set foo]



On Tue, 7 Jun 2005, Hans Herrmann wrote:

Hi,
last time you helped me with a problem:

###################

set a 1,0
set b 2,0
foreach pos {a b} {
 regsub -all {,} [set $pos] {.} [set pos]
}

######################

Why i must not do "$$pos" or "[eval puts $pos]" and for the seconde
substitution "$pos".

I don't quite understand what you mean with all that (especially that [eval puts $pos] lost me), but I think you get a clue when you read what [regsub] takes as parameters:
regsub ?switches? expr value repl varname
As pos goes through a and b you must feed a value to regsub ([set $pos] translates to [set a] and [set b], giving out correct values) and then you must provide some variable where to store substituted string ([set pos] goes to a and b).


But otherwise, there is no difference between '$foo' and 'set foo'. Except that latter is longer.

I'm not a specialist in programming, I'm a "hobby-tcler"

So am I :) Sorry to bother if that didn't help.

--
-Kaitzschu
s="TCL ";while true;do echo -en "\r$s";s=${s:1:${#s}}${s:0:1};sleep .1;done
.