U. Windl
U. Windl

Reputation: 4325

How (if at all) can I use Perl POD documentation in a shell script?

I wonder: In Perl POD is recognized partially by the Perl parser, and there is the __END__ keyword to stop Perl parsing. If I want to write POD in a shell script (maybe at the end of the script), can that be done, and if so: How?

Upvotes: 0

Views: 101

Answers (1)

user1934428
user1934428

Reputation: 22227

A dummy here document can be used in the shell to make it ignore the POD contents, while perldoc will be able to find it. Like this:

#!/bin/bash
#... usual shell commands here ...
echo "Hello, world"
# POD starts here
: <<'__POD__'
=pod

=head1 NAME

The hello-world program...
Blabla..

=cut

__POD__

Doing a sh podtest runs the script. Doing a perldoc podtest shows the doc. Newer versions of perldoc (like 3.28) may require option -F to find the POD.

Upvotes: 2

Related Questions