Perl Language Strings and quoting methods Heredocs


Example

Large Multi-Line strings are burdensome to write.

my $variable = <<'EOF';
this block of text is interpreted literally,
no \'quotes matter, they're just text
only the trailing left-aligned EOF matters.
EOF

NB: Make sure you ignore stack-overflows syntax highlighter: It is very wrong.

And Interpolated Heredocs work the same way.

my $variable = <<"I Want it to End";
this block of text is interpreted.
quotes\nare interpreted, and $interpolations
get interpolated... 
but still, left-aligned "I Want it to End" matters.
I Want it to End

Pending in 5.26.0* is an "Indented Heredoc" Syntax which trims left-padding off for you

5.26.0
my $variable = <<~"MuchNicer";
    this block of text is interpreted.
    quotes\nare interpreted, and $interpolations
    get interpolated... 
    but still, left-aligned "I Want it to End" matters.
MuchNicer