Perl: Here-Doc String

By Xah Lee. Date: .

Here-Doc String is a syntax useful for quoting multiple lines of long string.

There are two syntax:

Interpolated Here-Doc

Start the quote by on a newline:

<<random_letters

end the quote by the same random_letters on a line by itself:

random_letters

$ss = 9;

$xx = <<bbBvg;
i have $ss cats,
and something.
bbBvg

print $xx

__DATA__

prints

i have 9 cats,
and something.

Literal Here-Doc

Syntax of Literal Here-Doc is similar to the interpolated syntax, except you start the quote by

<<'random_letters'

$ss = 9;

$xx = <<'frrTy';
i have $ss cats,
and something.
frrTy

print $xx

__DATA__

prints

i have $ss cats,
and something.

Perl String