which like Perl has the same effect as not surrounding the tag with anything at all. Ruby The following Ruby code displays a grocery list by using a here document. puts <<GROCERY_LIST Grocery list ---- 1. Salad mix. 2. Strawberries.* 3. Cereal. 4. Milk.* * Organic GROCERY_LIST The result: $ ruby grocery-list.rb Grocery list ------------ 1. Salad mix. 2. Strawberries.* 3. Cereal. 4. Milk.* * Organic The << in a here document does not indicate input redirection, but Ruby also uses << for input redirection, so redirecting to a file from a here document involves using << twice, in different senses: File::open("grocery-list", "w") do |f| f << <<GROCERY_LIST Grocery list ---- 1. Salad mix. 2. Strawberries.* 3. Cereal. 4. Milk.* * Organic GROCERY_LIST end As with Unix shells, Ruby also allows for the delimiting identifier not to start on the first column of a line, if the start of the here document is marked with the slightly different starter <<-. Besides, Ruby treats here documents as a double-quoted string, and as such, it is possible to use the #{} construct to interpolate code. The following example illustrates both of these features: now = Time.now puts <<-EOF It's #{now.hour} o'clock John, where are your kids? EOF Ruby expands on this by providing the "<<~" syntax for omitting indentation on the here document: puts <<~EOF This line is indented two spaces. This line is indented four spaces. This line is indented six spaces. EOF The common indentation of two spaces is omitted from all lines: $ ruby indented-heredoc.rb This line is indented two spaces. This line is indented four spaces. This line is indented six spaces. Like Perl, Ruby allows for starting multiple here documents in one line: puts <<BEGIN + "<--- middle --->\n" + <<END This is the beginning: BEGIN And now it is over! END # this equals this expression: puts "This is the beginning:\n<--- middle --->\nAnd now it is over!" As with Perl, Ruby features file literals, namely the contents of the file following on a line by itself. This is accessible as the file object DATA and can be viewed as a form of data segment. Python Python supports multi-line strings as a "verbatim" string. They may be enclosed in 3 single (') or double (") quotation marks, the latter is shown in the examples below. print(""" Customer: Not much of a cheese shop is it? Shopkeeper: Finest