Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Get reference to newly-created array

by almut (Canon)
on Oct 22, 2007 at 18:00 UTC ( [id://646522]=note: print w/replies, xml ) Need Help??


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

    Thanks, almut. That's exactly what I'm looking for.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://646522]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-18 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found