Perl Language Strings and quoting methods Heredocs

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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


Got any Perl Language Question?