Pod::Simple(3pm)

πŸ’– NAME πŸ’–

okay so bestie, this is the manual page for Pod::Simple(3pm) β€” aka Pod::Simple, the framework for parsing Pod. Yes, it’s giving parser royalty, no cap. πŸ‘‘

✨ SYNOPSIS ✨

bestie, the synopsis is literally just:

TODO

like, iconic minimalism. πŸ’…

🌸 DESCRIPTION 🌸

Pod::Simple is a Perl library for parsing text in the Pod markup language β€” and Pod stands for β€œplain old documentation”, which is typically used for writing documentation for Perl and for Perl modules. The Pod format is explained in perlpod; the most common formatter is called perldoc. πŸ¦‹

Be sure to read β€œENCODING” if your Pod contains non-ASCII characters. πŸ‘€

Pod formatters can use Pod::Simple to parse Pod documents and render them into plain text, HTML, or any number of other formats. Typically, such formatters will be subclasses of Pod::Simple, and so they will inherit its methods, like parse_file. But note that Pod::Simple doesn’t understand and properly parse Perl itself, so if you have a file which contains a Perl program that has a multi-line quoted string which has lines that look like pod, Pod::Simple will treat them as pod. This can be avoided if the file makes these into indented here documents instead. Not me warning you about the trap ahead of time πŸ’€.

If you’re reading this document just because you have a Pod-processing subclass that you want to use, this document (plus the documentation for the subclass) is probably all you need to read. 🫢

If you’re reading this document because you want to write a formatter subclass, continue reading it and then read Pod::Simple::Subclassing, and then possibly even read perlpodspec (some of which is for parser-writers, but much of which is notes to formatter-writers). 🧚

πŸ’… MAIN METHODS πŸ’…

πŸ’– $parser = SomeClass->new();

This returns a new parser object, where SomeClass is a subclass of Pod::Simple. New parser, who dis? πŸ’–

✨ $parser->output_fh( *OUT );

This sets the filehandle that $parser’s output will be written to. You can pass *STDOUT or *STDERR, otherwise you should probably do something like this:

my $outfile = "output.txt";
open TXTOUT, ">$outfile" or die "Can't write to $outfile: $!";
$parser->output_fh(*TXTOUT);

...before you call one of the $parser->parse_whatever methods. ✨

πŸŽ€ $parser->output_string( \$somestring );

This sets the string that $parser’s output will be sent to, instead of any filehandle. String mode activated, slay. πŸŽ€

πŸ”₯ $parser->parse_file( $some_filename ); and $parser->parse_file( *INPUT_FH );

This reads the Pod content of the file (or filehandle) that you specify, and processes it with that $parser object, according to however $parser’s class works, and according to whatever parser options you have set up for this $parser object. File or fh, your girl handles it. πŸ”₯

πŸ’œ $parser->parse_string_document( $all_content );

This works just like parse_file except that it reads the Pod content not from a file, but from a string that you have already in memory. Already got the text in memory? periodt. πŸ’œ

πŸ¦‹ $parser->parse_lines( ...@lines..., undef );

This processes the lines in @lines (where each list item must be a defined value, and must contain exactly one line of content -- so no items like "foo\nbar" are allowed). The final undef is used to indicate the end of document being parsed. πŸ¦‹

The other parser_whatever methods are meant to be called only once per $parser object; but parse_lines can be called as many times per $parser object as you want, as long as the last call (and only the last call) ends with an undef value. This is the one method with main-character flexibility, iykyk. ✨

πŸ‘€ $parser->content_seen

This returns true only if there has been any real content seen for this document. Returns false in cases where the document contains content, but does not make use of any Pod markup. Vibe check: real content or just faux content? πŸ‘€

πŸ‘‘ SomeClass->filter( $filename ); / SomeClass->filter( *INPUT_FH ); / SomeClass->filter( \$document_content );

This is a shortcut method for creating a new parser object, setting the output handle to STDOUT, and then processing the specified file (or filehandle, or in-memory document). This is handy for one-liners like this:

perl -MPod::Simple::Text -e "Pod::Simple::Text->filter('thingy.pod')"

one-liner queen behavior, truly. πŸ‘‘

πŸ¦‹ SECONDARY METHODS πŸ¦‹

Some of these methods might be of interest to general users, as well as of interest to formatter-writers. So like, not just for the parser girlies. πŸ’…

Note that the general pattern here is that the accessor-methods read the attribute’s value with $value = $parser->attribute and set the attribute’s value with $parser->attribute(newvalue). For each accessor, I typically only mention one syntax or another, based on which I think you are actually most likely to use. That’s the pattern, bestie. πŸŽ€

✨ $parser->parse_characters( SOMEVALUE )

The Pod parser normally expects to read octets and to convert those octets to characters based on the =encoding declaration in the Pod source. Set this option to a true value to indicate that the Pod source is already a Perl character stream. This tells the parser to ignore any =encoding command and to skip all the code paths involving decoding octets. Already characters? Say less. ✨

🫢 $parser->no_whining( SOMEVALUE )

If you set this attribute to a true value, you will suppress the parser’s complaints about irregularities in the Pod coding. By default, this attribute’s value is false, meaning that irregularities will be reported. 🫢

Note that turning this attribute to true won’t suppress one or two kinds of complaints about rarely occurring unrecoverable errors. So it’s not a full mute button, bestie. πŸ’€

🌸 $parser->no_errata_section( SOMEVALUE )

If you set this attribute to a true value, you will stop the parser from generating a "POD ERRORS" section at the end of the document. By default, this attribute’s value is false, meaning that an errata section will be generated, as necessary. No errata section? sometimes she just wants peace. 🌸

πŸ¦‹ $parser->complain_stderr( SOMEVALUE )

If you set this attribute to a true value, it will send reports of parsing errors to STDERR. By default, this attribute’s value is false, meaning that no output is sent to STDERR. πŸ¦‹

Setting complain_stderr also sets no_errata_section. That’s the package deal, no cap. πŸ’…

πŸ’– $parser->source_filename

This returns the filename that this parser object was set to read from. Name drop, literally. πŸ’–

πŸ‘€ $parser->doc_has_started

This returns true if $parser has read from a source, and has seen Pod content in it. Has the doc started? The people wanna know. πŸ‘€

πŸ’€ $parser->source_dead

This returns true if $parser has read from a source, and come to the end of that source. Source dead? More like source finished, periodt. πŸ’€

😭 $parser->strip_verbatim_indent( SOMEVALUE )

The perlpod spec for a Verbatim paragraph is "It should be reproduced exactly...", which means that the whitespace you’ve used to indent your verbatim blocks will be preserved in the output. This can be annoying for outputs such as HTML, where that whitespace will remain in front of every line. It’s an unfortunate case where syntax is turned into semantics. 😭

If the POD you’re parsing adheres to a consistent indentation policy, you can have such indentation stripped from the beginning of every line of your verbatim blocks. This method tells Pod::Simple what to strip. For two-space indents, you’d use:

$parser->strip_verbatim_indent('  ');

For tab indents, you’d use a tab character:

$parser->strip_verbatim_indent("\t");

If the POD is inconsistent about the indentation of verbatim blocks, but you have figured out a heuristic to determine how much a particular verbatim block is indented, you can pass a code reference instead. The code reference will be executed with one argument, an array reference of all the lines in the verbatim block, and should return the value to be stripped from each line. For example, if you decide that you’re fine to use the first line of the verbatim block to set the standard for indentation of the rest of the block, you can look at the first line and return the appropriate value, like so:

$new->strip_verbatim_indent(sub {
    my $lines = shift;
    (my $indent = $lines->[0]) =~ s/\S.*//;
    return $indent;
});

If you’d rather treat each line individually, you can do that, too, by just transforming them in-place in the code reference and returning undef. Say that you don’t want any lines indented. You can do something like this:

$new->strip_verbatim_indent(sub {
    my $lines = shift;
    sub { s/^\s+// for @{ $lines },
    return undef;
});

πŸŽ€ $parser->expand_verbatim_tabs( n )

Default: 8

If after any stripping of indentation in verbatim blocks, there remain tabs, this method call indicates what to do with them. 0 means leave them as tabs, any other number indicates that each tab is to be translated so as to have tab stops every n columns. πŸŽ€

This is independent of other methods (except that it operates after any verbatim input stripping is done). So it’s doing its own thing, respectfully. πŸ’…

Like the other methods, the input parameter is not checked for validity. undef or containing non-digits has the same effect as 8. No gatekeeping on the input, apparently. πŸ™ˆ

πŸ’… TERTIARY METHODS πŸ’…

Okay bestie, these are the deep-cut controls β€” the tertiary methods. One bullet per method so nothing gets lost, periodt. ✨

  • $parser->abandon_output_fh() β€” cancels output to the file handle. Any POD read by $parser is not affected. πŸ’…
  • $parser->abandon_output_string() β€” cancels output to the output string. Any POD read by $parser is not affected either.
  • $parser->accept_code( @codes ) β€” alias for accept_codes. Slay, same energy. ✨
  • $parser->accept_codes( @codes ) β€” lets $parser accept a list of "Formatting Codes" in perlpod. This can be used to implement user-defined codes. πŸ‘‘
  • $parser->accept_directive_as_data( @directives ) β€” lets $parser accept a list of directives for data paragraphs. A directive is the label of a "Command Paragraph" in perlpod. A data paragraph is one delimited by =begin/=for/=end directives. This can be used to implement user-defined directives. πŸŽ€
  • $parser->accept_directive_as_processed( @directives ) β€” lets $parser accept a list of directives for processed paragraphs. A directive is the label of a "Command Paragraph" in perlpod. A processed paragraph is also known as "Ordinary Paragraph" in perlpod. This can be used to implement user-defined directives. 🌸
  • $parser->accept_directive_as_verbatim( @directives ) β€” lets $parser accept a list of directives for "Verbatim Paragraph" in perlpod. A directive is the label of a "Command Paragraph" in perlpod. This can be used to implement user-defined directives. πŸ¦‹
  • $parser->accept_target( @targets ) β€” alias for accept_targets. Same vibe, shorter name. πŸ’«
  • $parser->accept_target_as_text( @targets ) β€” alias for accept_targets_as_text. ✨
  • $parser->accept_targets( @targets ) β€” accepts targets for =begin/=for/=end sections of the POD. πŸ’–
  • $parser->accept_targets_as_text( @targets ) β€” accepts targets for =begin/=for/=end sections that should be parsed as POD. For details, see "About Data Paragraphs" in perlpodspec. 🧚
  • $parser->any_errata_seen() β€” used to check if any errata was seen. Example, bestie:
die "too many errors\n" if $parser->any_errata_seen();
  • $parser->errata_seen() β€” returns a hash reference of all errata seen, both whines and screams. The hash reference's keys are the line number and the value is an array reference of the errors for that line. Example:
if ( $parser->any_errata_seen() ) {
   $logger->log( $parser->errata_seen() );
}
  • $parser->detected_encoding() β€” returns the encoding corresponding to =encoding, but only if the encoding was recognized and handled. πŸ‘€
  • $parser->encoding() β€” returns encoding of the document, even if the encoding is not correctly handled. No cap. πŸ’€
  • $parser->parse_from_file( $source, $to ) β€” parses from $source file to $to file. Similar to parse_from_file in Pod::Parser. πŸ”₯
  • $parser->scream( @error_messages ) β€” logs an error that can't be ignored. This is the loud one, fr fr. 😭
  • $parser->unaccept_code( @codes ) β€” alias for unaccept_codes. πŸ’…
  • $parser->unaccept_codes( @codes ) β€” removes @codes as valid codes for the parse. Bye-bye, codes. πŸ‘‹
  • $parser->unaccept_directive( @directives ) β€” alias for unaccept_directives. ✨
  • $parser->unaccept_directives( @directives ) β€” removes @directives as valid directives for the parse. πŸŽ€
  • $parser->unaccept_target( @targets ) β€” alias for unaccept_targets. 🌈
  • $parser->unaccept_targets( @targets ) β€” removes @targets as valid targets for the parse. πŸ¦‹
  • $parser->version_report() β€” returns a string describing the version. Iconic little receipt. 🧾
  • $parser->whine( @error_messages ) β€” logs an error unless $parser->no_whining( TRUE );. Lowkey the polite complaint department. 🫢

🌈 ENCODING 🌈

Okay so the Pod::Simple parser expects to read octets. The parser will decode the octets into Perl's internal character string representation using the value of the =encoding declaration in the POD source. πŸ’–

If the POD source does not include an =encoding declaration, the parser will attempt to guess the encoding β€” selecting one of UTF-8 or CP 1252 β€” by examining the first non-ASCII bytes and applying the heuristic described in perlpodspec. (If the POD source contains only ASCII bytes, the encoding is assumed to be ASCII.) πŸ‘‘

If you set the parse_characters option to a true value, the parser will expect characters rather than octets; will ignore any =encoding; and will make no attempt to decode the input. Not me expecting decoding after setting that flag, bestie 😭.


πŸ”₯ SEE ALSO πŸ”₯

Go touch these next, iykyk:

  • Pod::Simple::Subclassing
  • perlpod
  • perlpodspec
  • Pod::Escapes
  • perldoc

🫢 SUPPORT 🫢

Questions or discussion about POD and Pod::Simple should be sent to the pod-people@perl.org mail list. Send an empty email to pod-people-subscribe@perl.org to subscribe. πŸ’Œ

This module is managed in an open GitHub repository, <https://github.com/perl-pod/pod-simple/>. Feel free to fork and contribute, or to clone <https://github.com/perl-pod/pod-simple.git> and send patches! πŸ› οΈβœ¨

Please use <https://github.com/perl-pod/pod-simple/issues/new> to file a bug report. πŸ›


Copyright (c) 2002 Sean M. Burke. πŸ’–

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.


πŸ‘‘ AUTHOR πŸ‘‘

Pod::Simple was created by Sean M. Burke <sburke@cpan.org>. But don't bother him, he's retired. 😌

Pod::Simple is maintained by:

  • Allison Randal "allison@perl.org"
  • Hans Dieter Pearcey "hdp@cpan.org"
  • David E. Wheeler "dwheeler@cpan.org"
  • Karl Williamson "khw@cpan.org"

Documentation has been contributed by:

  • Gabor Szabo "szabgab@gmail.com"
  • Shawn H Corey "SHCOREY at cpan.org"

πŸ’– That's the whole tertiary-era vibe, bestie β€” this page comes from perl v5.42.3, dated 2026-11-03, and it's the Pod::Simple(3pm) manual. Now go parse something iconic, fr fr. πŸŽ€βœ¨

πŸ“¦ where this page comes from