在 Perl 函数中打印自由格式文本?
当尝试在 Perl 的子例程中打印自由格式文本时,我遇到了一个非常奇怪的错误。下面是我调用的代码
print OUTFILE <<"HEADER";
The freeform text would go here
HEADER
奇怪的是,这只适用于我的函数的主要部分。一旦我将它放入函数调用中,我就会收到此错误:
Can't find string terminator "HEADER" anywhere before EOF
这意味着它无法找到标头,即使它在那里。不能在函数(子例程)中使用自由格式文本吗?
I have been getting a very odd error when trying to print freeform text in a subroutine in Perl. Below is the code I am calling
print OUTFILE <<"HEADER";
The freeform text would go here
HEADER
The odd thing is that this only works in the main of my function. As soon as I place it in a function call, I get this error:
Can't find string terminator "HEADER" anywhere before EOF
Meaning it can't find the HEADER, even though it is there. Can you not use freeform text within a function (subroutine)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保结束字符串标识符(即
HEADER
)之前没有空格/制表符/缩进。您的代码应如下所示:请注意,在
HEADER
之前没有空格/制表符/缩进。它应该从该行的第一个字符开始。查看本教程以获取更多信息:
引用:
Make sure that there is no space/tab/indentation before ending string identifier, that is
HEADER
. Your code should look like this:Notice that there is no space/tab/indentation before
HEADER
there. It should start from first character of its line.Check this tutorial out for more information:
Quoting: