Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
You all might know programs like git, svn or mp4box where you can ask for a general help and specific help like:
svn help commit
I've started today a script which also has several commands like svn has and so I'd like to have a similar way to present help, but I can't figure out how to utilize Pod::Usage for this. I have to add that unfortunately the Pod::Usage version on the target system is at V1.33 :(
Update: My initial idea was to have one POD for each of the commands.
Does anyone have any useful tipps for me?
Update #2 Thanks to dasgar I think I found a way:
I defined a sub to which I pass an option list like pod2usage expects. The option "-pod" defines the name of the pod I want, while the rest is simply passed on to pod2usage.
#!/usr/bin/perl use strict; use warnings; use Pod::Usage; pod( -pod => 'test', -verbose => 2 ); sub pod { my(%options)= @_; my $pod_text; SWITCH: for ($options{-pod}) { /^main$/ && do { $pod_text=<<'POD'; =head1 NAME Main =head1 SYNOPSIS main.pl [options] =head1 DESCRIPTION This is main =cut POD last SWITCH; }; /^test$/ && do { $pod_text=<<'POD'; =head1 NAME Test =head1 SYNOPSIS Test.pl [options] =head1 DESCRIPTION This is Test =cut POD last SWITCH; }; return; } delete $options{-pod}; delete $options{-input}; open my $pod_file, '<', \$pod_text; pod2usage( -input => $pod_file, %options ) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pod::Usage - Can I have multiple Pods in one script?
by VinsWorldcom (Prior) on Jan 19, 2016 at 21:57 UTC | |
by Skeeve (Parson) on Jan 20, 2016 at 06:15 UTC | |
|
Re: Pod::Usage - Can I have multiple Pods in one script?
by Mr. Muskrat (Canon) on Jan 19, 2016 at 21:55 UTC | |
by Skeeve (Parson) on Jan 20, 2016 at 06:14 UTC | |
|
Re: Pod::Usage - Can I have multiple Pods in one script?
by dasgar (Priest) on Jan 19, 2016 at 22:08 UTC | |
by Skeeve (Parson) on Jan 20, 2016 at 06:19 UTC | |
|
Re: [Solved] Pod::Usage - Can I have multiple Pods in one script?
by thomas895 (Deacon) on Jan 20, 2016 at 22:47 UTC | |
by Skeeve (Parson) on Jan 21, 2016 at 06:12 UTC |