If I'm going to bother with command line options, I almost always use Getopt::Long. It's big, but it works quite well (I really like that it removes the options from @ARGV so I can use <> later, and that it can do some validation of the options, etc).
--isotope
http://www.skylab.org/~isotope/
| [reply] |
I like -s. It lets me do things like:
#!/usr/bin/perl -ws
use strict;
our ($name, $age, $sex);
# ...
and run the code like: prog.pl -name="Jeff Pinyan" -sex=male -age=19. I even got 10 characters or so added to Perl's source code to allow double-hyphens (if you're into that sort of thing).
japhy --
Perl and Regex Hacker | [reply] [d/l] |
I like Getopt::Mixed, which
lets you use either "-abc=foo",
"--alpha --beta --cletus=foo",
or, "--alpha -bc=foo".
### EZ way:
use Getopt::Mixed;
Getopt::Mixed::getOptions qw(
help h>help
file f>file
list=i l>list
);
print "$opt_help, $opt_file, $opt_list";
### 'Harder' way (more flexible, but you have more to write):
use Getopt::Mixed "nextOption";
Getopt::Mixed::init
qw(
help h>help
file f>file
id=i i>id
);
my ($opt_id, $opt_file, $opt_help);
while (($option, $value, $pretty) = nextOption()) {
if ($option eq 'id') {
$opt_id = $value;
}
elsif ($option eq 'help') {
# etc.
}
}
-- Frag. | [reply] [d/l] |
I'm with isotope. I find that command line parms with longer names are easier to remember. I generally use Getopt::Long something like this:
GetOptions("file=s" => \my $input_file,
"verbose" => \$VERBOSE,
"help" => \my $HELP)
or die "Insert usage message here";
Getopt::Long is also flexible enough to allow bundling of single-character options like Getopt::Std.
- robsv | [reply] [d/l] |