Version 2 of Here document

Updated 2008-01-28 00:20:54 by EKB

From the Wikipedia article [L1 ], find:

"A here document (also called a here-document or a heredoc), is a way of specifying a string literal in shells such as Bash, Windows PowerShell and the Bourne Shell, as well as programming languages such as Perl, PHP, Python and Ruby. It preserves the line breaks and other whitespace (including indentation) in the text. Some languages allow variable interpolation or even code to be evaluated inside of the string."


EKB Since in Tcl, everything is a string, it seems to me that every Tcl program is a heredoc, of the sort that "allow(s) variable interpolation or even code to be evaluated inside of the string." To get a heredoc of the sort that doesn't have any interpolation or evaluation, use curly braces. For example, the sample Ruby code from Wikipedia,

 puts <<GROCERY_LIST
 Grocery list
 ------------
 1. Salad mix.
 2. Strawberries.*
 3. Cereal.
 4. Milk.*

 * Organic
 GROCERY_LIST

can be implemented this way:

 puts {Grocery list
 ------------
 1. Salad mix.
 2. Strawberries.*
 3. Cereal.
 4. Milk.*

 * Organic}