Logo

Programming-Idioms

History of Idiom 48 > diff from v2 to v3

Edit summary for version 3 by :

Version 2

2015-07-31, 20:15:11

Version 3

2015-07-31, 20:15:56

Idiom #48 Multi-line string litteral

Assign to variable s a string litteral consisting in several lines of text

Idiom #48 Multi-line string litteral

Assign to variable s a string litteral consisting in several lines of text

Code
$s = "Perl normally allows
strings to contain newlines.";

$s =<<EOSTR;
However, it also provides the "here doc" (lifted from various UNIX shells).
A 'here doc' is the <<tag construct.  Perl continues to treat
all the text found as part of the string until there's a line containing
the EOSTR tag at the beginning
EOSTR
Code
$s = "Perl normally allows
strings to contain newlines.";
$s = q{
There are a good few ways to create multiline
text strings in perl.
};
$s =<<EOSTR;
One of them is called the "here doc" (lifted from various UNIX shells).
A 'here doc' is the <<tag construct.  Perl continues to treat
all the text found as part of the string until there's a line containing
the EOSTR tag at the beginning
EOSTR