here 文档

大型多线字符串很难写。

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

注意:确保忽略堆栈溢出语法高亮显示:这是非常错误的。

插值的 Heredocs 以同样的方式工作。

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

在 5.26.0 *中待定是一个“缩进的 Heredoc”语法,它会为你修剪左边的填充

Version >= 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