可能重复:
Perl 中多行注释的常见解决方法是什么?
如何在 Perl 源代码中添加多行注释?
POD is the official way to do multi line comments in Perl,
来自 faq.perl.org[ perlfaq7 ]
注释掉多行 Perl 的快速而简单的方法是用 Pod 指令包围这些行。你必须把这些指令放在行首和 Perl 期望新语句的地方(所以不要放在像 # 注释这样的语句中间)。你用 结束评论
=cut
,结束 Pod 部分:
=pod
my $object = NotGonnaHappen->new();
ignored_sub();
$wont_be_assigned = 37;
=cut
只有当您不打算将注释代码保留在源代码中时,快速而肮脏的方法才有效。如果出现 Pod 解析器,您的多行注释将显示在 Pod 翻译中。一种更好的方法也可以将其从 Pod 解析器中隐藏起来。
该
=begin
指令可以为特定目的标记一个部分。如果 Pod 解析器不想处理它,它就会忽略它。用 标记评论comment
。=end
使用相同的标签结束评论。您仍然需要=cut
从 Pod 注释返回到 Perl 代码:
=begin comment
my $object = NotGonnaHappen->new();
ignored_sub();
$wont_be_assigned = 37;
=end comment
=cut
我找到了。Perl 有多行注释:
#!/usr/bin/perl
use strict;
use warnings;
=for comment
Example of multiline comment.
Example of multiline comment.
=cut
print "Multi Line Comment Example \n";