in reply to Multi-line comments in perl code?
I think it's useful to boil down what's already been said or referred to.
- POD is the official way to do multi line comments in Perl, whether you think of it as as a work-around or not (which varies),
- use "=for comment" or "=begin/end comment" for stuff that's just comments and shouldn't show up in the output text when documentation is extracted from the code, such as when you run perldoc on the program,
- You can't indent the "=for comment", so it's not quite like other language's multiline comments, and
- You do need a "=cut" at the end to get back to code. (I think this might be your main objection to using POD, and, yes, you're stuck with it).
Here's an example which you can runn with "perl" and with "perldoc" to see what shows up where. Note that in many places, such as before the "=cut", the blank line is part of the syntax.
=head1 tstcmt.pl This is text that shows up with the "perldoc tstcmt.pl" command. The comment sections below do not. =cut print "hello\n"; =for comment This is a single paragraph of comment text, spanning multiple lines. It ends with the first blank line. After that, the text is inuded with other printed pod text that shows up with perldoc This text also shows up with perldoc, it's not part of the "for" comment above. =cut print "hello1\n"; =for comment Another paragraph of comment text, spanning multiple lines. It ends with the first blank line. =cut print "hello2\n"; =begin comment This is a multi-paragraph comment section. Which is terminated by an =end comment on a line by itself. This is a second paragraph =end comment =cut print "hello3\n"; =head2 Other pod documentation This is text that also shows up with the "perldoc tstcmt.pl" command. The comment sections above do not. =cut print "hello4\n"
In Section
Seekers of Perl Wisdom