derek5. 2010-09-30 06:11 采纳率: 100%
浏览 197
已采纳

如何在 Perl 中输入多行注释? [重复]

Possible Duplicate:
What are the common workarounds for multi-line comments in Perl?

How do I add a multi-line comment to Perl source code?

转载于:https://stackoverflow.com/questions/3828205/how-do-i-enter-a-multi-line-comment-in-perl

  • 写回答

2条回答 默认 最新

  • 程序go 2010-09-30 06:29
    关注
    POD is the official way to do multi line comments in Perl,
    

    From faq.perl.org[perlfaq7]

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题