I know this is ancient, but since it's high on the Google hit list, I wanted to mention one thing...
This very cool trick does not work for @arrays. :-(
This:
does *NOT* DWIM. According to "perlref":use Getopt::Long; GetOptions( 'single=s' => \(my $single = ''), 'multi=s' => \(my @multi = ()), );
As a special case, "\(@foo)" returns a list of references to the contents of @foo, not a reference to @foo itself.I tried all kinds of permutations, and the best I could come up with was:
which, isn't quite as clean, IMHO.use Getopt::Long; GetOptions( 'single=s' => \(my $single = ''), 'multi=s' => do { use vars '@multi'; \@multi }, );
(It *DOES*, however, keep the variable declarations and command-line options on the same line, at least, so you don't have to make changes in multiple places when adding new options. *shrug*)
In reply to Re^3: GetOpt::Long usage style
by OneTrueDabe
in thread GetOpt::Long usage style
by demerphq
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |