Hi

I had a discussion with Ilya Zakharevich about how cperl-mode in emacs should fold perl-code in respect to embedded POD.

I'm a big fan of literal programming, DRY and encapsulation but holding the documentation in close vicinity to the code doesn't seem to be that easy in perl...

Do I get right that the only "straighforward" way to achieve this with CPAN-like POD-structure is by splitting POD into two surrounding parts and preceding every sub by

=head2 ... =cut
parts?

=head1 NAME =head1 VERSION =head1 SYNOPSIS =head1 DESCRIPTION =cut # some nonsub perlcode #======================================== =head1 METHODS intro about methods ... =cut #---------------------------------------- =head2 load ($source, -opt1 => $val1, ...) text describing load() =cut sub load { #body #body #body } #---------------------------------------- =head2 parse ($string, -opt1 => $val1, ...) text describing parse() =cut sub parse { #body #body #body } #======================================== =head1 SEE ALSO =head1 AUTHOR =head1 BUGS =head1 ACKNOWLEDGEMENTS =head1 COPYRIGHT & LICENSE =cut
UPDATE: thats how the resulting man page looks like:
NAME
VERSION
SYNOPSIS
DESCRIPTION
METHODS
       intro about methods ...

       load ($source, -opt1 => $val1, ...)

       text describing load()

       parse ($string, -opt1 => $val1, ...)

       text describing parse()

SEE ALSO
AUTHOR
BUGS
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE

Cheers Rolf


In reply to [literate programming] How to mix POD with code? And how to fold this? by LanX

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.