This RFC mentions
Unlike many programming languages Perl does not currently implement true multiline comments. This, and the workarounds that are in common use can be problematic. This could be solved by adding a new syntax to allow for comments to span more than one line, like the variation on here-documentation cited below.
What are the common workarounds?
Two techniques I found here are
if (0) { <comment> }
and
=pod <comment> =cut
Are these safe to use? Are there others that work better?
In Perl, multi-line comments are also known as block comments and are defined using “=begin” at the start of the line and “=end” at the end of the comment line, and the other way of using block comments is by using quote operators q{}.
In Python script, the symbol # indicates start of comment line. A triple quoted multi-line string is also treated as comment if it is not a docstring of a function or class.
To comment out multiple lines in Python, you can prepend each line with a hash ( # ).
The downside of the "if" solution is that the commented out code still has to be compiled (and therefore still has to be syntax checked).
The downside of your pod solution is that your comments will appear in any documentation generated from the pod.
I use a version of the pod solution that doesn't have that problem. Pod supports =begin format
... =end format
paragraphs that are handled by specific formatters. I just invent a "comment" format that isn't handled by any of the formatters I use.
#!/usr/bin/perl print "This line is executed\n"; =begin comment print "This line isn't\n"; =end comment =cut print "This line is\n";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With