perl 多行注释
2014-08-17 19:28:31 阿炯

perl中只支持以'#'开头的单行注释,如果想注释一个代码块,通用的方法是在行前加'#',但这样做会比较麻烦,下面将介绍一种区块注释的方法;使用pod文档的方法,可快速地批量注释一段代码块。

POD is the official way to do multi line comments in Perl,comment out a large block of Perl code.POD是官方的在Perl中多行注释的方法,可用于注释掉一大块Perl代码。

From faq.perl.org[perlfaq7][在FAQ 7中的建议]

The quick-and-dirty way to comment out more than one line of Perl is to surround those lines with Pod directives. You have to put these directives at the beginning of the line and somewhere where Perl expects a new statement (so not in the middle of statements like the # comments). You end the comment with =cut, ending the Pod section:

=pod
my $object = FreeOA->new();
ignored_sub();
$wont_be_assigned = 37;
=cut

使用标签

The =begin directive can mark a section for a particular purpose. If the Pod parser doesn't want to handle it, it just ignores it. Label the comments with comment. End the comment using =end with the same label. You still need the =cut to go back to Perl code from the Pod comment.

=begin指令可以在某一节上做某个特定的标记。如果Pod解析器不想处理它,就会忽略它,它用于标记注释。使用=end以相同的标签结束注释。您仍然需要从Pod注释线束标记(=cut)中返回到Perl代码。这个与有多层循环中打标记相类似。

=begin comment
my $object = FreeOA->new();
ignored_sub();
$wont_be_assigned = 37;
=end comment

=cut