summaryrefslogtreecommitdiff
path: root/lib/Getopt
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.berkeley.edu>2003-06-03 17:45:23 -0700
committerJarkko Hietaniemi <jhi@iki.fi>2003-09-16 18:47:52 +0000
commit669ecdbcc9859cccd0b304b919aa0725f0097a2a (patch)
tree785615a9de488c05561018d33189be8df092ba43 /lib/Getopt
parenta104b4331c3ff1891c34087e511cd28d9ba39c56 (diff)
downloadperl-669ecdbcc9859cccd0b304b919aa0725f0097a2a.tar.gz
Re: [PATCH 5.8.1 @19053] Getopt::Std
Message-ID: <20030604074523.GA7148@math.berkeley.edu> p4raw-id: //depot/perl@21245
Diffstat (limited to 'lib/Getopt')
-rw-r--r--lib/Getopt/Std.pm18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Getopt/Std.pm b/lib/Getopt/Std.pm
index 99e9269676..1783adb123 100644
--- a/lib/Getopt/Std.pm
+++ b/lib/Getopt/Std.pm
@@ -55,6 +55,9 @@ the output file handle, the name of option-processing package, its version,
and the switches string. If the subroutines are not defined, an attempt is
made to generate intelligent messages; for best results, define $main::VERSION.
+If embedded documentation (in pod format, see L<perlpod>) is detected
+in the script, C<--help> will also show how to access the documentation.
+
Note that due to excessive paranoia, if $Getopt::Std::STANDARD_HELP_VERSION
isn't true (the default is false), then the messages are printed on STDERR,
and the processing continues after the messages are printed. This being
@@ -186,12 +189,27 @@ sub help_mess ($;$) {
}
my ($scr) = ($0 =~ m,([^/\\]+)$,);
print $h <<EOH if @_; # Let the script override this
+
Usage: $scr [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...]
EOH
print $h <<EOH;
+
The following single-character options are accepted:$help
+
Options may be merged together. -- stops processing of options.$arg
EOH
+ my $has_pod;
+ if ( defined $0 and $0 ne '-e' and -f $0 and -r $0
+ and open my $script, '<', $0 ) {
+ while (<$script>) {
+ $has_pod = 1, last if /^=(pod|head1)/;
+ }
+ }
+ print $h <<EOH if $has_pod;
+
+For more details run
+ perldoc -F $0
+EOH
}
}