Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How can I turn a string into a variable name?

by ikegami (Patriarch)
on Jan 09, 2010 at 19:13 UTC ( [id://816524]=note: print w/replies, xml ) Need Help??


in reply to How can I turn a string into a variable name?

Don't.

GetOptions( '--one' => \$one, '--two' => \$two, '--three' => \$three, ); die "Only one of options --one, --two and --three are allowed\n" if ( grep defined, $one, $two, $three ) > 1;
or
GetOptions( '--one' => \$opts{one}, '--two' => \$opts{two}, '--three' => \$opts{tree}, ); die "Only one of options @{[ sort keys %opts ]} are allowed\n" if ( grep defined, values(%opts) ) > 1;

Update: Updated since I hadn't properly read the question initially.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-20 02:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found