There are many way to do it but I found the following particulary useful and versatile: The Dynamic Duo --or-- Holy Getopt::Long, Pod::UsageMan!
Infact Pod::Usage can semplfy a lot such part of a program: it can shows sections of your choice of the POD embed in the program (I'm used to put the POD after the __DATA__ token), it has the ability to modify the exit value with the useful NOEXIT feature.
The module can semplify a lot the help and manual commandline options; let's see it's recommendend usage:
use strict; use Pod::Usage; use Getopt::Long; ## Parse options my %opt; GetOptions(\%opt, "help|?", "man", "flag1") || pod2usage(2); pod2usage(1) if ($opt{help}); pod2usage(-exitval => 0, -verbose => 2) if ($opt{man}); ## Check for too many filenames pod2usage("$0: Too many files given.\n") if (@ARGV > 1);
L*
In reply to Re: how to write script usage sub routine for the perl file? the dynamic duo with Pod::Usage
by Discipulus
in thread how to write script usage sub routine for the perl file?
by perlanswers
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |