in reply to Get reference to newly-created array
[] and do { my @array; \@array }, will both create an array and return a reference to it, but the array will be anonymous. No good.
You could use prototype trickery to do what you want.
sub get_array_ref(\@) { $_[0] } GetOptions( 'array=s' => get_array_ref(my @array) ); print("@array\n");
By the way, it's =s when you pass a reference to an array, and =s@ when you pass a reference to a scalar. That opens up another possibility:
GetOptions( 'array=s@' => \(my $array) ); print("@$array\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get reference to newly-created array
by benizi (Hermit) on Oct 22, 2007 at 21:58 UTC | |
by ikegami (Patriarch) on Oct 23, 2007 at 01:42 UTC |