"Getopt::Auto" is happy for you to use "long" ("--gnu-style"), "short"
("-oldstyle") or even "bare" command names, ("myprogram edit foo.txt",
CVS-style) on the condition that you are consistent. Additionally, if
you use bare or long style commands, then any short options passed
before a command name will be sent into %main::options. For instance,
given
use Getopt::Auto (
"edit" => "open a file for editing",
"export" => "write out the data as an ASCII file"
);
"yourprog -vt edit -x foo.txt" will perform the following:
$main::options{v} = 1
$main::options{t} = 1
edit("-x", "foo.txt");
####
#!/usr/bin/perl
use strict;
use warnings;
# Test bed for Getopt::Auto
use Getopt::Auto ( [
"edit" => "open a file for editing",
"export" => "write out the data as an ASCII file"
] );
our %options;
{
print "Dump arguments!!\n";
foreach ( keys %main::options ) {
print "$_ : $main::options{$_}\n";
}
}
####
[alex@foo dev]$ perl -w go.pl -vt edit -x foo.txt
Dump arguments!!
Use of uninitialized value in subroutine entry at /usr/lib/perl5/site_perl/5.8.0/Getopt/Auto.pm line 140.
Can't use string ("") as a subroutine ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.0/Getopt/Auto.pm line 140.
END failed--call queue aborted.