in reply to Seeking Getopt recommendations - anyone used Getopt::Easy?
I agree with what's been said here. I too haven't used Getopt::Easy, but use Getopt::Long all of the time. The main reason to not use Getopt::Easy that I can see would be that it isn't a CORE module and would need to be installed on every machine where it is used.
While we're sharing coding idioms.... here is what I always do for commandline arguments:
use strict; use Getopt::Long; # Main body eval { my $options = { 'help' => 0, 'verbose' => 0, 'config' => '/etc/myapp.conf', }; GetOptions( 'help' => \$$options{help}, 'verbose!' => \$$options{verbose}, 'config=s' => \$$options{config}, ); }; print "ERROR: $@" if $@;
This lets you set defaults for your options and GetOptions() handles any commandline overrides by the user.
Frank Wiles <frank@revsys.com>
www.revsys.com
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Seeking Getopt recommendations - anyone used Getopt::Easy?
by gaal (Parson) on Jan 09, 2007 at 17:28 UTC | |
by ides (Deacon) on Jan 10, 2007 at 14:38 UTC |