This assumes the following:
  1. That you have pod in your script.
  2. That you are using Getopt::Std. (Else modify for however you are processing command line options.)
  3. That you have -h as a command line option that you will accept without arguments, whose presence indicates that you will display a help screen instead of running.
This implements the -h option.
if ($opt_h) { exec("perldoc", $0) or die "Cannot execute 'perldoc': $!"; }

Replies are listed 'Best First'.
Re: Easy help for scripts
by chromatic (Archbishop) on Sep 10, 2001 at 06:40 UTC
    Enter Pod::Usage (will be a core module in Perl 5.8):
    use Pod::Usage; pos2usage() if $opt_h;
      Nice, but I would tend to use that for an invalid invocation, and use the full documentation for a help screen. YMMV.

      UPDATE
      chromatic pointed out to me that you can get the full documentation out of Pod::Usage. But not as easily, and without the convenient pager behaviour...