Hello Monks,

I was finding ways to use multi line comments (v5.22.0) and found perlfaq7 section "How can I comment out a large block of Perl code?" The two ways suggested there are:

=pod . . =cut
And
=begin comment . . . =end comment =cut

But when I was playing with it I noticed that using pairs of "=cut" also does the same without any warning/error, with use strict and warnings.

=cut . . . =cut

But I am not sure if it's safe or recommended as perlpodspec section "=cut" says that:

It is an error to try to start a Pod block with a "=cut" command. In that case, the Pod processor must halt parsing of the input file, and must by default emit a warning.

Also Excess =cut breaks module has some views against using pair of =cut for multi line commenting.

So I was hoping to get some views on if it's recommended or safe to use pairs of "=cut" for multi line commenting in production code? I felt pairs of "=cut" is easier to remember than "=pod" or "=begin/end comment".

I am using following simple test code for trying this out:

#!/opt/apps/perl/perl5220/bin/perl use strict; use warnings; print "Line1\n"; print "Line2\n"; =cut print "Line3\n"; =cut print "Line4\n"; =cut print "Line5\n"; =cut print "Line6\n";

In reply to Is it safe/recommended to use pairs of =cut for multi line comments? by Perl300

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.