可能重複:
What are the common workarounds for multi-line comments in Perl?如何在Perl中輸入多行註釋?
如何添加到Perl的源代碼中的多行註釋?
可能重複:
What are the common workarounds for multi-line comments in Perl?如何在Perl中輸入多行註釋?
如何添加到Perl的源代碼中的多行註釋?
POD is the official way to do multi line comments in Perl,
從faq.perl.org [perlfaq7]
快速和骯髒的方式來註釋掉多行的Perl是 用Pod指令包圍這些行。您必須將這些 指令放在行的開始位置以及Perl 需要新語句的位置(因此不要在# 註釋之類的語句中間)。你最終的評論與
=cut
,結束了莢狀部分:
=pod
my $object = NotGonnaHappen->new();
ignored_sub();
$wont_be_assigned = 37;
=cut
快速和骯髒的方法僅效果很好,當你不打算離開 註釋代碼源。如果一個Pod分析器出現,您的多行註釋將出現在Pod翻譯中。 A 更好的方法也將它從Pod解析器中隱藏起來。
指令可以爲特定目的標記段。如果 Pod分析器不想處理它,它只是忽略它。標籤 與
comment
的評論。使用=end
和 相同的標籤結束註釋。你仍然需要=cut
從 波德評論回去Perl代碼:
=begin comment
my $object = NotGonnaHappen->new();
ignored_sub();
$wont_be_assigned = 37;
=end comment
=cut
沒有必要用= POD開始評論,你可以使用任何東西來開始多行評論(比如說= xyz等)但是是結束必須總是= = cut not even = CUT – Bharat 2014-06-13 04:44:06
我找到了。 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";
之間'=爲comment'和' = cut',從第二段開始,它將顯示在* perldoc *中。所以只有第一段可以從代碼和* perldoc *中完全評論。如果應該避免這種情況,可以使用'= begin comment' ...多行/段落註釋...'=結束註釋(* new-line *)= cut'。 – 2012-10-15 03:26:56
根本就 =頭 ##你的代碼進行評論 =削減 – TheBlackCorsair 2012-12-07 14:24:09