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

Re: Dynamic option

by ikegami (Patriarch)
on Mar 16, 2011 at 03:40 UTC ( #893487=note: print w/replies, xml ) Need Help??


in reply to Dynamic option

I was surprised a feature was recently added to Getopt::Long (2.35, to be specific) to addresses this very need!

$ perl -MData::Dumper -MGetopt::Long -e' my %options = ( input => [] ); GetOptions(\%options, "input=s{0,}", "des=s", "r=i") or die; print(Dumper(\%options)); ' -- -input data modem apps -des "finding files" -r 1000 $VAR1 = { 'r' => 1000, 'input' => [ 'data', 'modem', 'apps' ], 'des' => 'finding files' };

It's marked as experimental.

Replies are listed 'Best First'.
Re^2: Dynamic option
by Anonymous Monk on Mar 16, 2011 at 03:57 UTC

    Thanks but my problem is on how to access these options?.I want to run a for loop for all the options entered <code>

      Hi,is there a way to add options to option values?meaning ,in the below example the option is "input" and it's values are data,modem,apps but for these values I want to add options (-nd -na -nc)?Can someone pls advise how can I achieve that?

      EXAMPLE:- findfiles -input [-nd -na ] data [-nc -nd] modem apps -des "finding fi +les" -r 1000 Basically ,pseudco code of what I want to achieve is below.Really appr +eciate if someone can give me the perlversion of the code. for each "input option value" { call function A if not exits nd call function B if not exits na call function C if not exists nc }
        You'll need a different parser.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2023-09-25 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?