in reply to Get reference to newly-created array
As long as you don't need to initialise the array, you should be fine if you simply omit the parentheses. For example
#!/usr/bin/perl use Getopt::Long; GetOptions( 'thing=s' => \(my $thing = ''), 'flag' => \(my $flag = 0), 'array=s' => \my @array, # no parens # ... ) or die 'options'; print "\@array: @array\n";
when called as
$ ./646480.pl -a foo -a bar -a baz
would print as expected
@array: foo bar baz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get reference to newly-created array
by benizi (Hermit) on Oct 22, 2007 at 23:32 UTC |