Mike Mike - 4 months ago 8
Perl Question

Does Perl have the equivalent of Python's multiline strings?

In Python you can have a multiline string like this using a docstring

foo = """line1
line2
line3"""


Is there something equivalent in Perl?

Answer

Perl doesn't have significant syntactical vertical whitespace, so you can just do

$foo = "line1
line2
line3
";

which is equivalent to

$foo = "line1\nline2\nline3\n";
Comments