in reply to Can anyone please to modify this perl code

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);

Replies are listed 'Best First'.
Re^2: Can anyone please to modify this perl code
by Anonymous Monk on Jun 02, 2005 at 11:34 UTC
    Hi
    Thanks a lot for your help.
    Regards, Sur