How do you like the following:
#!/usr/bin/perl use strict; use warnings; use Pod::Usage qw( pod2usage ); use Getopt::Long qw( GetOptions ); sub program_options { my ($options) = @_; GetOptions( 'help' => \{$options->{help}}, 'verbose' => \{$options->{verbose}}, 'name:s' => \{$options->{name}}, ) or die "Couldn't read command line options"; my @errors; push @errors, "Input is required\n" unless $options{name}; pod2usage(@errors) if @errors; if (@errors || $options{help}) { pod2usage(<<'__EOI__'); Usage: To execute: perl ProgramName <argument> Help: perl ProgramName --help or perl ProgramName --h __EOI__ die("\n"); } } # Get command line options my %options; program_options(\%options);
In reply to Re: Can anyone please to modify this perl code
by ikegami
in thread Can anyone please to modify this perl code
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |