# 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 \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; }