
pod2text Command in Linux
The pod2text command in Linux converts a POD file to an ASCII text file. A POD file is a plain-text file written in POD (Plain Old Documentation) format, a lightweight and simple markup language primarily used for documenting Perl scripts, modules, and programs.
Converting POD to text makes Perl documentation easily readable and shareable in plain text format.
Table of Contents
Here is a comprehensive guide to the options available with the pod2text command −
Syntax of pod2text Command
Here is the syntax of the Linux pod2text command −
pod2text [options] [POD-file]
The [options] field in the above syntax is used to specify various options to change the command's behavior. The [POD-file] field is used to specify the POD file that needs to be converted to text.
pod2text Command Options
The options of the pod2text command are listed below −
Flags | Options | Description |
---|---|---|
-a | --alt | Use alternate output formatting with a distinct heading style and mark =item entries with a colon. |
--code | Include non-POD text from the input file in the output. | |
-c | --color | Format output with ANSI color sequences (requires Term::ANSIColor) |
-i <spaces> | --indent=<spaces> | Set text and =over block indentation (default: 4 spaces) |
-h | --help | Show usage information and exit |
-l | --loose | Add a blank line after =head1 headings for arbitrary text documents |
-m <width> | --margin=<width> | Set left margin width for all text (default: 0) |
-o | --overstrike | Use overstrike formatting for bold and italics |
-q <chars> | --quotes=<chars> | Define quote marks for C<> text (supports single, paired, or none) |
-s | --sentence | Preserve double spaces between sentences |
--stderr | Output errors to standard error instead of adding a POD ERRORS section | |
-t | --termcap | Use terminal settings for screen width and text formatting (requires Term::Cap) |
-u | --utf8 | Force UTF-8 output encoding (input must declare proper encoding) |
-w <cols> | --width=<cols> | Wrap text at specified column width (default: 76) |
Examples of pod2text Command in Linux
In this section, the usage of the pod2text command in Linux will be discussed with examples −
Converting a POD File to a Text File
To convert a POD file to a text file, use the pod2text command with the POD file name −
pod2text file.pod

The above command displays the output text in the standard output as shown in the output image.
To save the converted output to a file, specify the file name as given in the following command −
pod2text file.pod output.txt

Using Alternate Output Format
To use the alternate output format, use the -a or --alt option −
pod2text -a file.pod output.txt

The -a option enables an alternate output format with different heading styles and =item entries marked by a colon (:) in the left margin for clarity.
Getting Colored Output
To add the ANSI color format to the output, use the -c or --color option −
pod2text -c file.pod output.txt
Note that using this option requires the Term::ANSIColor module to be installed on Linux.
Changing Indentation
To modify the indentation of the output, use the -i, or --indent option with a number of spaces. To add 5 spaces for indentation, use the pod2text command in the following way −
pod2text -i 5 file.pod output.txt
Using Loose Formatting
To add a blank line after each =head1 heading, use the -l or --loose option −
pod2text -l file.pod output.txt

Modifying Margins
By default, the left margin is 0. To change the left margin of the output, use the -m or --margin option with width −
pod2text -m 3 file.pod output.txt

The above command adds 3 spaces from left to the output.
Setting Text Wrap
To set a custom text wrap, use the -w or --width option −
pod2text -w 100 file.pod output.txt
The default text wrapping is 76 characters.
Preserving Double Spaces between Sentences
To preserve double spaces between sentences instead of compressing consecutive whitespaces, use the -s or --sentence option −
pod2text -s file.pod output.txt
By default, the double spaces are compressed to one.
Using Terminal Settings for Text Wrapping
To use the terminal settings such as screen width and text formatting, use the -t or --term option with the pod2text command −
pod2text -t file.pod output.txt
The output wraps two columns less than the terminal's width. For example, if the terminal width is 90 characters, the text wraps at 88 characters.
Displaying Usage Help
To display the usage help, use the -h or --help option −
pod2text -h
Conclusion
The pod2text command in Linux converts POD (Plain Old Documentation) files into plain ASCII text. It offers many options, such as alternate formatting styles, ANSI color output, customized indentation, margin settings, and text wrapping. The output can be saved to a file or displayed on the terminal as needed. The command supports preserving spaces between sentences and utilizing terminal settings for optimal formatting.