gpt4 book ai didi

perl - Perl中多行注释的常见解决方法是什么?

转载 作者:行者123 更新时间:2023-12-03 09:00:39 27 4
gpt4 key购买 nike

This RFC 提及

Unlike many programming languages Perl does not currently implement true multiline comments. This, and the workarounds that are in common use can be problematic. This could be solved by adding a new syntax to allow for comments to span more than one line, like the variation on here-documentation cited below.



常见的解决方法是什么?

我发现 here的两种技术是
if (0) {
<comment>
}


=pod
<comment>
=cut

这些安全使用吗?还有其他人做的更好吗?

最佳答案

“if”解决方案的不利之处在于,注释掉的代码仍必须进行编译(因此仍然必须进行语法检查)。

pods 解决方案的缺点是,您的评论将出现在由 pods 生成的任何文档中。

我使用的Pod解决方案版本没有这个问题。 Pod支持=开头格式... =特定格式程序处理的结束格式段落。我只是发明了一种“注释”格式,该格式未由我使用的任何格式化程序处理。

=begin comment

This is ignored by everything

=end comment

更新:

我错过了示例中的重要部分。您需要以= cut结束pod部分。这是一个完整的例子。
#!/usr/bin/perl

print "This line is executed\n";

=begin comment

print "This line isn't\n";

=end comment

=cut

print "This line is\n";

关于perl - Perl中多行注释的常见解决方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3608957/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com