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 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题