【发布时间】:2022-06-27 21:58:42
【问题描述】:
我在 web 服务器后面有一个 perl 代码,我将 perl 脚本与纯 html 结合起来,重要的部分如下所示:
#!/usr/local/bin/perl
use strict;
use warnings;
print "Content-type: text/html\n\n";
print <<ENDHTML;
<!DOCTYPE html>
<html lang="hu">
<head>
...
</head>
<body class="landing">
...
<section class="feature 6u$ 12u$(small)">
<h3 class="title">some title</h3>
<p>some text</p>
</section>
...
</body>
</html>
ENDHTML
当有人打开网页时,这个错误信息会出现在日志中:
2022/06/27 13:28:44 [error] 7811#100158: *106 FastCGI sent in stderr: "Use of uninitialized value $12 in concatenation (.) or string at /path/to/file/index.pl line 78.
我知道这是因为use warnings;,如果我禁用它,那么日志中不会出现任何内容。但是,如果我可以忽略从 print <<ENDHTML; 到 ENDHTML 的脚本部分,那就太好了,因为它们是 html 代码的一部分。有没有办法做到这一点,我也可以use warnings;?
【问题讨论】: