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:
use Getopt::Long;
GetOptions(
'single=s' => \(my $single = ''),
'multi=s' => \(my @multi = ()),
);
does *NOT* DWIM. According to "perlref":
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:
use Getopt::Long;
GetOptions(
'single=s' => \(my $single = ''),
'multi=s' => do { use vars '@multi'; \@multi },
);
which, isn't quite as clean, IMHO.
(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*)