Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
# Get command line options %options = program_options() or die "Error!"; sub program_options { my ( %options, @informations, @errors, ); use Pod::Usage; # Get command line options use Getopt::Long; GetOptions('help!' => \$options{help}, 'verbose' => \$options{verbose}, 'name:s' => \$options{name}, ) or die "Couldn't read command line options"; push @informations, "Usage:\n To execute: perl ProgramName <argument>\ +n Help: perl ProgramName --help or perl ProgramName --h" if $options{ +help); pod2usage (join "\n", @informations) if @informations; # Exit with usage if any needed option is missing push @errors, "Input is required" unless $options{name}; pod2usage (join "\n", @errors) if @errors; }
Retitled by holli from 'Can anyone please'.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with Getopt::Long and Pod::Usage
by dragonchild (Archbishop) on May 31, 2005 at 13:54 UTC | |
|
Re: Need help with Getopt::Long and Pod::Usage
by newest_newbie (Acolyte) on May 31, 2005 at 14:51 UTC | |
|
Re: Need help with Getopt::Long and Pod::Usage
by herveus (Prior) on Jun 01, 2005 at 12:08 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |