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"; } }