Perl300 has asked for the wisdom of the Perl Monks concerning the following question:
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:
And=pod . . =cut
=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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is it safe/recommended to use pairs of =cut for multi line comments?
by haukex (Archbishop) on Jun 10, 2016 at 17:09 UTC | |
|
Re: Is it safe/recommended to use pairs of =cut for multi line comments?
by LanX (Saint) on Jun 10, 2016 at 17:16 UTC | |
|
Re: Is it safe/recommended to use pairs of =cut for multi line comments? [No: it's a syntax error]
by kcott (Archbishop) on Jun 10, 2016 at 21:30 UTC | |
|
Re: Is it safe/recommended to use pairs of =cut for multi line comments?
by Marshall (Canon) on Jun 10, 2016 at 17:51 UTC | |
|
Re: Is it safe/recommended to use pairs of =cut for multi line comments?
by Laurent_R (Canon) on Jun 10, 2016 at 17:50 UTC | |
|
Re: Is it safe/recommended to use pairs of =cut for multi line comments?
by ww (Archbishop) on Jun 10, 2016 at 21:33 UTC | |
|
[Solved]: Is it safe/recommended to use pairs of =cut for multi line comments?
by Perl300 (Friar) on Jun 10, 2016 at 19:07 UTC |