networktestinggenius.tk
Your networking tutor
Exclusive networking testing notes
Learn Networking & Testing topics

Substitution
There are three kinds of substitutions in TCL.
Command substitution : Square brackets are used for command substitution.
Variable substitution : $ dollar sign is used for Variable substitution
Backslash substitution: With the backslash substitution, we escape the original meaning of the character.
Command substitution :
puts [expr 2+2]
Output:
4
The expr command is used to perform arithmetic calculations. First, the command between the square brackets is evaluated and the result is returned to the puts command. The puts command then evaluates the result and prints it to the console.
Variable substitution :
set name Thiru
puts name
puts $name
Output:
name
Thiru
The dollar-sign and the following characters are replaced in the word by the value of a variable. We create a variable called name and set a value to it.
puts name In this case, we print a string "name" to the console.
puts $name In the second case, the argument is preceded by the $ character. The value of the name variable is printed to the console.
Backslash substitution:
puts "This is \t thiru"
This is thiru
Here the \t sequence is replaced with a tab.
puts "My name is \"Thiru\""
puts "The \\ character is the backslash character"
Output:
My name is "Thiru"
The \ character is the backslash character
For example, the \n stands for a new line and the \t is the tab character.