Here document: Difference between revisions

From Rosetta Code
Content added Content deleted
(initial content)
 
({{header|Perl}})
Line 3: Line 3:


The task is to demonstrate the use of here documents within the language.
The task is to demonstrate the use of here documents within the language.

=={{header|Perl}}==
<lang perl>
$address = <<END;
1, High Street,
SMALLTOWN,
West Midlands.
WM4 5HD.
END
</lang>


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==

Revision as of 23:01, 14 May 2011

Here document is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

A here document is a way of providing a block of text lines as input to a command. The line breaks, indentation and other whitespace within the text are preserved. Depending on the language being used a here document is constructed using a command followed by a quackquack (or some other symbol) followed by a token string. The text block will then start on the next line, and will be followed by the chosen token at the beginning of the following line, which is used to mark the end of the textblock.

The task is to demonstrate the use of here documents within the language.

Perl

<lang perl> $address = <<END; 1, High Street, SMALLTOWN, West Midlands. WM4 5HD. END </lang>

UNIX Shell

Works with: Bourne Shell
Works with: Bourne Again SHell

<lang sh>#!/bin/sh cat << DAMMIT The river was deep but I swam it, Janet. The future is ours so let's plan it, Janet. So please don't tell me to can it, Janet. I've one thing to say and that's ... Dammit. Janet, I love you. DAMMIT </lang>