Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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).
The last item may change with Perl6, for "=begin/end", but the rest will probably not. See Apocalypse 2 RFC 5

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 reply to Re: Multi-line comments in perl code? by rodion
in thread Multi-line comments in perl code? by mrguy123

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2022-10-02 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (7 votes). Check out past polls.

    Notices?