Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

check pod documents for syntax errors

podchecker - check pod documents for syntax errors


Pod::Checker, podchecker() - check pod documents for syntax errors


  use Pod::Checker;

  $syntax_okay = podchecker($filepath, $outputpath, %options);

  my $checker = new Pod::Checker %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 it defaults to \*STDIN, and the output-file defaults to \*STDERR.


This function can take a hash of options:

-warnings => val
Turn warnings on/off. See Warnings.


podchecker will perform syntax checking of Perl5 POD format documentation.


It is hoped that curious/ambitious user will help flesh out and add the 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 preformed:

  • Unknown '=xxxx' commands, unknown 'X<...>' interior-sequences, and unterminated interior sequences.

  • Check for proper balancing of =begin and =end. The contents of such a block are generally ignored, i.e. no syntax checks are performed.

  • Check for proper nesting and balancing of =over, =item and =back.

  • Check for same nested interior-sequences (e.g. L<...L<...>...>).

  • Check for malformed or nonexisting entities E<...>.

  • Check for correct syntax of hyperlinks L<...>. See perlpod for details.

  • Check for unresolved document-internal links. This check may also reveal misspelled links that seem to be internal links but should be links to something else.




These may not necessarily cause trouble, but indicate mediocre style.

  • multiple occurence of link target name
  • The POD file has some =item and/or =head commands that have the same text. Potential hyperlinks to such a text cannot be unique then.

  • line containing nothing but whitespace in paragraph
  • There is some whitespace on a seemingly empty line. POD is very sensitive to such things, so this is flagged. vi users switch on the list option to avoid this problem.

  • file does not start with =head
  • The file starts with a different POD directive than head. This is most probably something you do not want.

  • No numeric argument for =over
  • The =over command is supposed to have a numeric argument (the indentation).

  • previous =item has no contents
  • There is a list =item right above the flagged line that has no text contents. You probably want to delete empty items.

  • preceding non-item paragraph(s)
  • A list introduced by =over starts with a text or verbatim paragraph, but continues with =items. Move the non-item paragraph out of the =over/=back block.

  • =item type mismatch (one vs. two)
  • A list started with e.g. a bulletted =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.

  • N unescaped <> in paragraph
  • Angle brackets not written as <lt> and <gt> can potentially cause errors as they could be misinterpreted as markup commands.

  • Unknown entity
  • A character entity was found that does not belong to the standard ISO set or the POD specials verbar and sol.

  • No items in =over
  • The list opened with =over does not contain any items.

  • No argument for =item
  • =item without any parameters is deprecated. It should either be followed by * to indicate an unordered list, by a number (optionally followed by a dot) to indicate an ordered (numbered) list or simple text for a definition list.

  • empty section in previous paragraph
  • The previous section (introduced by a =head command) does not contain any text. This usually indicates that something is missing. Note: A =head1 followed immediately by =head2 does not trigger this warning.

  • Verbatim paragraph in NAME section
  • The NAME section (=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.

  • Hyperlinks
  • There are some warnings wrt. hyperlinks: Leading/trailing whitespace, newlines in hyperlinks, brackets ().


podchecker returns the number of POD syntax errors found or -1 if there were no POD commands at all found in the file.




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.

$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:


A message to print prior to @args.


The line number the error occurred in.


The file (name) the error occurred in.


The error level, should be 'WARNING' or 'ERROR'.

Set (if argument specified) and retrieve the number of errors found.

Set (if argument specified) and retrieve the canonical name of POD as found in the =head1 NAME section.

Add (if argument specified) and retrieve the nodes (as defined by =headX and =item) of the current POD. The nodes are returned in the order of their occurence. They consist of plain text, each piece of whitespace is collapsed to a single blank.

Add (if argument specified) and retrieve the 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.

Add (if argument specified) and retrieve the hyperlinks (as defined by L<>) of the current POD. They consist of an 2-item array: line number and Pod::Hyperlink object.


Brad Appleton <> (initial version), Marek Rouchal <>

Based on code for Pod::Text::pod2text() written by Tom Christiansen <>