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

如何在Perl中输入多行注释?

发布时间:2020-12-15 21:29:20 所属栏目:大数据 来源:网络整理
导读:Possible Duplicate: 07000 如何向Perl源代码添加多行注释? 解决方法 POD is the official way to do multi line comments in Perl, 见Multi-line comments in perl code和 Better ways to make multi-line comments in Perl更多 详情。 来自faq.perl.org [

Possible Duplicate:
07000

如何向Perl源代码添加多行注释?

解决方法

POD is the official way to do multi line comments in Perl,

>见Multi-line comments in perl
code和
> Better ways to make multi-line comments in Perl更多
详情。

来自faq.perl.org [perlfaq7]

> How can I comment out a large block
of Perl code?

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 = NotGonnaHappen->new();

ignored_sub();

$wont_be_assigned = 37;

=cut

The quick-and-dirty method only works well when you don’t plan to
leave the commented code in the source. If a Pod parser comes along,
your multiline comment is going to show up in the Pod translation. A
better way hides it from Pod parsers as well.

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 comment

my $object = NotGonnaHappen->new();

ignored_sub();

$wont_be_assigned = 37;

=end comment

=cut

(编辑:李大同)

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

    推荐文章
      热点阅读