I haven't completely figured it out, but I have determined that you can add a head1 with code like this:
use Pod::POM; my $parser = Pod::POM->new(); my $pom = $parser->parse_file(...); my $h1 = $pom->add($parser, 'head1', 'This is a new head1');
and the new head1 will appear at the end of the POD. However, I don't think it will be easy to add a a head1 section in the middle of the document (in case you want your sections to follow a uniform ordering). In that case, something like this might work for you:
my @SECTIONS = qw(name synopsis ...); my $pom = $parser->parse_file(...); my %found; for my $h1 ($pom->head1()) { $found{lc($h1->title)} = $h1; } for my $title (@SECTIONS) { my $h1; if ($h1 = $found{$title}) { print $h1; } else { print "=head1 ", uc($title), "\n\n"; } }
Of course, this code silently discards sections that are not listed in @SECTIONS which is probably not what you want to do, but it at least is a start.

In reply to Re: check pod and insert missing sections by pc88mxer
in thread check pod and insert missing sections by leocharre

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.