加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 21:24:11 所属栏目:大数据 来源:网络整理
导读: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
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”解决方案的缺点是,注释掉的代码仍然需要编译(因此仍然需要语法检查)。

您的pod解决方案的缺点是您的注释将显示在从pod生成的任何文档中。

我使用的pod解决方案没有这个问题的版本。 Pod supports = begin format … =由特定格式化程序处理的结束格式段落。我只是发明了一个“注释”格式,不是由我使用的任何格式化程序。

=begin comment

This is ignored by everything

=end comment

更新:

我错过了我的例子的一个重要部分。您需要使用= cut结束pod部分。这里有一个完整的例子。

#!/usr/bin/perl

print "This line is executedn";

=begin comment

print "This line isn'tn";

=end comment

=cut

print "This line isn";

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读