Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Backslash sequence inTcl

Posted by skumar003 (skumar003), 6 February 2003
What is the use of backslash sequence in Tcl?


set  path  [pwd]
set  tcc \\
set  path &path$tcc

where is my path finally set to? Is this for use in windows to fetch a file?


Posted by admin (Graham Ellis), 7 February 2003
The \ character in Tcl gives an alternative meaning to the next chartacter.    

If you write backslash followed by a special character, then the following character is not treated as special - you're telling Tcl that you REALLY want that second character as just a normal character, even if it would normally do something special.

If you write a backslash followed by a letter or digit, then the following character has a special significance not normally associated with it.

  \$    I want a $ character
  \\     I really want a \ character
  \n    I want a newline character

Your example code

set  path  [pwd]
    set path to contain the result of running the pwd command
set  tcc \\
    set tcc to contain a single \ character
set  path &path$tcc
    overwrite path with the string "&path" followed by the
    contents of the variable tcc,  giving  &path\

A further complication of \  ... It ALSO has special meanings in regular expressions, and if you need to have it in a regular expression you have to get it through the Tcl interpretter.  Thus it's quite common to see a regular expression command than includes something like
which means "I REALLY want to look for a *".   The Tcl interpretter reduces the string above to
which is the "I really want a *" to the regular expression handler.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho