Pod::Checker — check pod documents for syntax errors
| Use Case | Command | Description |
|---|---|---|
| Check POD syntax | podchecker($filepath, $outputpath, %options) | Basic syntax check; returns number of errors |
| Check with warnings | podchecker($filepath, $outputpath, -warnings => 1) | Enable warnings for style issues |
| Object-oriented check | my $checker = Pod::Checker->new(%options); $checker->parse_from_file($filepath, \*STDERR); | Using the OO interface for more control |
| Suppress output | podchecker($filepath, $outputpath, -quiet => 1) | Only return error count, no printed messages |
| Get hyperlinks | $checker->hyperlinks() | Retrieve array of external link objects |
use Pod::Checker;
$syntax_okay = podchecker($filepath, $outputpath, %options);
my $checker = Pod::Checker->new(%options);
$checker->parse_from_file($filepath, \*STDERR);
$filepath is the input POD to read and $outputpath is where to write POD syntax error messages. Either argument may be a scalar indicating a file-path, or else a reference to an open filehandle. If unspecified, the input-file defaults to \*STDIN, and the output-file defaults to \*STDERR.
This function can take a hash of options:
-warnings => val — Turn warnings on/off. val is usually 1 for on, but higher values trigger additional warnings. See Warnings.-quiet => val — If val is true, do not print any errors/warnings.podchecker will perform syntax checking of Perl5 POD format documentation.
Curious/ambitious users are welcome to propose additional features they wish to see in Pod::Checker and podchecker and verify that the checks are consistent with perlpod.
The following checks are currently performed:
=xxxx commands, unknown X<...> interior-sequences, and unterminated interior sequences.=begin and =end. The contents of such a block are generally ignored, i.e. no syntax checks are performed.=over, =item and =back.L<...L<...>...>).E<...>.L<...>. See perlpod for details.=head1 or =head2) without any text? That ain't no heading!=back before =headN, or =over is the last thing in the document. The =over command does not have a corresponding =back before the next heading (=head1 or =head2) or the end of the file.=item or =back command has been found outside a =over/=back block.=begin command was found that has no matching =end command.=begin command was found that is not followed by the formatter specification.=end command was found.=end directives need to have a target, just like =begin directives.=for command."".=head1, =head2, =head3, =head4, =over, =item, =back, =begin, =end, =for, =pod, =cut.B<>, C<>, E<>, F<>, I<>, L<>, S<>, X<>, Z<>.=pod and =cut do not take any arguments.=back command does not take any arguments.=cut directive found in the middle of non-POD.These may not necessarily cause trouble, but indicate mediocre style.
=item and/or =head commands that have the same text. Potential hyperlinks to such a text cannot be unique then. This warning is printed only with warning level greater than one.=item that has no text contents. You probably want to delete empty items.=over starts with a text or verbatim paragraph, but continues with =items. Move the non-item paragraph out of the =over/=back block.=item and continued with a numbered one. This is obviously inconsistent. For most translators the type of the first =item determines the type of the list.=item numbers; they need to ascend consecutively.verbar and sol. Currently, this warning only appears if a character entity was found that does not have a Unicode character. This should be fixed to adhere to the original warning.=over does not contain anything.=head command) does not contain any valid content. This usually indicates that something is missing. Note: A =head1 followed immediately by =head2 does not trigger this warning.=head1 NAME) should consist of a single paragraph with the script/module name, followed by a dash `-` and a very short description of what the thing is good for.=head2 in the POD file prior to a =head1.Z<> sequence is supposed to be empty. Caveat: this issue is detected in Pod::Simple and will be flagged as an ERROR by any client code; any contents of Z<...> will be disregarded, anyway.There are some warnings with respect to malformed hyperlinks:
L<...>.| and / are special in the L<...> context. Although the hyperlink parser does its best to determine which / is text and which is a delimiter in case of doubt, one ought to escape these literal characters like this: / E<sol>
| E<verbar>
Note that the line number of the error/warning may refer to the line number of the start of the paragraph in which the error/warning exists, not the line number that the error/warning is on. This bug is present in errors/warnings related to formatting codes. This should be fixed.
podchecker returns the number of POD syntax errors found or -1 if there were no POD commands at all found in the file.
See SYNOPSIS.
The podchecker script that comes with this distribution is a lean wrapper around this module. See the online manual with
podchecker -help
podchecker -man
While checking, this module collects document properties, e.g. the nodes for hyperlinks (=headX, =item) and index entries (X<>). POD translators can use this feature to syntax-check and get the nodes in a first pass before actually starting to convert. This is expensive in terms of execution time, but allows for very robust conversions.
Since v1.24 the Pod::Checker module uses only the poderror method to print errors and warnings. The summary output (e.g. "Pod syntax OK") has been dropped from the module and has been included in podchecker (the script). This allows users of Pod::Checker to control completely the output behavior. Users of podchecker (the script) get the well-known behavior.
v1.45 inherits from Pod::Simple as opposed to all previous versions inheriting from Pod::Parser. Do not use Pod::Simple's interface when using Pod::Checker unless it is documented somewhere on this page. I repeat, DO NOT USE POD::SIMPLE'S INTERFACE.
The following list documents the overrides to Pod::Simple, primarily to make Pod::Coverage happy:
end_Bend_Cend_Documentend_Fend_Iend_Lend_Paraend_Send_Xend_fcodeend_forend_headend_head1end_head2end_head3end_head4end_itemend_item_bulletend_item_numberend_item_texthandle_pod_and_cuthandle_texthandle_whitelinehyperlinkscreamstart_Bstart_Cstart_Datastart_Fstart_Istart_Lstart_Parastart_Sstart_Verbatimstart_Xstart_fcodestart_forstart_headstart_head1start_head2start_head3start_head4start_item_bulletstart_item_numberstart_item_textstart_overstart_over_blockstart_over_bulletstart_over_emptystart_over_numberstart_over_textwhinePod::Checker->new( %options )Return a reference to a new Pod::Checker object that inherits from Pod::Simple and is used for calling the required methods later. The following options are recognized:
-warnings => num — Print warnings if num is true. The higher the value of num, the more warnings are printed. Currently there are only levels 1 and 2.-quiet => num — If num is true, do not print any errors/warnings. This is useful when Pod::Checker is used to munge POD code into plain text from within POD formatters.$checker->poderror( @args ) / $checker->poderror( {%opts}, @args )Internal method for printing errors and warnings. If no options are given, simply prints @_. The following options are recognized and used to form the output:
-msg — A message to print prior to @args.-line — The line number the error occurred in.-file — The file (name) the error occurred in. Defaults to the name of the current file being processed.-severity — The error level, should be 'WARNING' or 'ERROR'.$checker->num_errors() / $checker->num_warnings() / $checker->name() / $checker->node() / $checker->idx() / $checker->hyperlinks()Set (if argument specified) and retrieve the respective property:
num_errors — number of errors found.num_warnings — number of warnings found.name — canonical name of POD as found in the =head1 NAME section.node — nodes (as defined by =headX and =item) of the current POD. The nodes are returned in the order of their occurrence. They consist of plain text, each piece of whitespace is collapsed to a single blank.idx — index entries (as defined by X<>) of the current POD. They consist of plain text, each piece of whitespace is collapsed to a single blank.hyperlinks — retrieve an array containing the hyperlinks to things outside the current POD (as defined by L<>). Each is an instance of a class with the following methods:line() — Returns the approximate line number in which the link was encountered.
type() — Returns the type of the link; one of: "url" for things like http://www.foo, "man" for man pages, or "pod".
page() — Returns the linked-to page or url.
node() — Returns the anchor or node within the linked-to page, or an empty string ("") if none appears in the link.
Please report bugs using <http://rt.cpan.org>.
Brad Appleton <bradapp AT enteract.com> (initial version), Marek Rouchal <marekr AT cpan.org>, Marc Green <marcgreen AT cpan.org> (port to Pod::Simple) Ricardo Signes <rjbs AT cpan.org> (more porting to Pod::Simple) Karl Williamson <khw AT cpan.org> (more porting to Pod::Simple)
Based on code for Pod::Text::pod2text() written by Tom Christiansen <tchrist AT mox.com>.
Generated by phpman v4.9.26-5-g7740029 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-21 03:23 @216.73.216.45
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)