Pod::Usage - POD document output
Pod::Usage is a module for outputting POD documents. You can use a function called pod2usage that displays the documentation and terminates the program.
If you use a function, it's a good idea to import it explicitly.
# Import function use Pod::Usage 'pod2usage';
This is the most basic usage example of pod2 usage. Exit the program by displaying the item "SYNOPSIS" in the document.
# The most basic usage of Pod::Usage =head1 SYNOPSIS script.pl FILE =cut use Pod::Usage 'pod2usage'; # Command line arguments my $file = shift; # If there is no argument, display SYNOPSIS and exit the program pod2usage () unless $file;
If there is no command line argument, the following will be displayed and the program will terminate.
Usage: script.pl FILE
This is an example that combines Pod::Usage and Getopt::Long.
# Combine Pod::Usage and Getopt::Long =head1 SYNOPSIS script.pl [- force] FILE =cut use Pod::Usage 'pod2usage'; use Getopt::Long 'GetOptions'; # Analysis of command line options my $force; GetOptions('force' => \$force) or pod2usage; my $file = shift; pod2usage unless $file;